Hacker Newsnew | past | comments | ask | show | jobs | submit | more BiteCode_dev's commentslogin

The fact you can rely on every API to allow duck typing is a core feature of the language. It has pros and cons, of course, like all features. But it is not an accident, it's by design.

And type hints have been designed with this in mind. It will stay that way.

If this is feature makes you unhappy, Python will make you unhappy. It's important to know what are the values that are important to you and chose your toolbox accordingly.


Isn't Python just a language? AFAIK there are many Python interpreters (or implementations), like CPython, Jython, IronPython,....

Couldn't a Python interpreter enforce type checking and raise errors whenever a type doesn't match? I'd be happy to use such an interpreter in many scenarios.


Tons of libs wouldn't work this way I guess, probably including stuff in the standard library. So you could really just use a subset of the Python ecosystem. I'm not sure it's worth the effort.


The standard library tends to work pretty well in general, but common libraries like boto will have problems.


Sure, you could also replace the indentation with open and close brackets, replace some keywords and change the standard lib to be like Java.

Or you could use Java which it seems is what you wanted to use in the first place and leave Python alone.


Yes, a language defined by a spec and PEP. And they define the way typing is done.

If you do it differently, you are not implementing python.


Thanks for your reply :)


I think it should be up to the API to specify which types are allowed, not the developer just hoping it works.

When you’ve worked on a sufficiently large and complex code base maybe you’ll understand.

Edit: coded in python for > 10 years. I prefer it over other languages, warts and all.


> I think it should be up to the API to specify which types are allowed, not the developer just hoping it works.

This assumes:

- the dev is thinking about the API

- the dev has the knowledge and experience to do it

- the dev has the resource/constraints that allow to do so

- dev has an interest in doing so

- this is a good investment for that particular project

Thinking in black and white does not make for good language design.

I'm glad Guido designed Python and said no to so many requests to make it no Python. Because he sure been pressured to.

> When you’ve worked on a sufficiently large and complex code base maybe you’ll understand.

I do.

I also understand Python projects that have a favorable cost/benefit ratio for type hints are not that many.

When you're used to hammer you see everything as a nail, and people loving a specific language feature tend to want it everywhere.

A huge number of dev in the Python community are not professional nor even experienced programmers. And a equally big number of projects have a size or a nature that makes type hint a bad value.

When you’ve worked on a sufficiently diverse project base maybe you’ll understand.


I really enjoy being able to write about 90-95% of python with type hints, the static checking and IDE autocomplete is fantastic, and the remaining just be like "ok computer just trust me".

Or when I'm doing data wrangling in jupyter and I never use type hints cause it's all just REPL rapid prototyping and I get autocomplete from the objects.


I think type hints make sense in some specific cases. Especially if it's an external API that your code is providing, or for when the usage is not clear.

It's good for checking the internal logic, but being optional is important in the python context.


Well...

file 'setupTests.ts' setupTests.ts: Java source, ASCII text

I wouldn't put too much trust in file.


I don’t know what you expected. File is just there to give a good guess at a file’s format. There are a ton of reasons why this problem is hard, and there are reasons to make “file” less accurate in order to make the implementation simpler and more secure.

But it will work fine for PDFs, often enough.


The heuristic used for Java source looks like this:

0 regex \^import.*;$ Java source


People are mostly looking at the death count, which is still very low for a pandemic.

It's hard to convince people to sacrifice so much when they look outside their windows and see nothing special, plus read the news and find that some bomb/earth quake/accident somewhere killed more people in a day than the corona virus in a month.


This is IMO one of the killer features of vue.

Sure, you can plug react components in a progressive way, but you still have to move the HTML into the JS file. And you certainly won't ship the babel behemoth to the client so, no JSX.

With Vue, you have a friendly migration path, with a style close to angular 1, if you need.

It's also awesome for prototyping or making quick and dirty projects.

Evan, every time I use Vue I can see how you pondered seriously those things. The docs are amazing. The API is full of little details that show you care (I smile every time I see you can do '.prevent" - "oh right, they though of that!").

It's not just a great product. It makes you feel the authors are your friends.

Thank you.


> The API is full of little details that show you care (I smile every time I see you can do '.prevent" - "oh right, they though of that!").

I tend to have the opposite reaction. I want a framework with a small API I can keep cached in my head. I don't want to worry about finding the magic switches to get it working the way I want.


I see that a lot in the JS world, "libraries over frameworks" and all that.

The result is that when you go from project to project, people solve the same problems, again and again, in a different way. And create their own custom abstractions, badly tested and documented.

Eventually, the API you could "keep cached in your head" lead to a system you MUST keep in your head because it's very hard to follow how things work and you need to remember it all to be productive. Debugging, extending and onboarding suffers.

Another consequence is that there is still no Django/RoR equivalent in JS. Building any medium size app is a total waste of time, doing the same boiler plate over and over for problems solved 10 years ago.

Everybody has a boilerplate one of course. Nothing is standardized, so the ecosystem is not reusable. Any pluggable library must carefully chosen, then be manually integrated in your own Frankenstein creature, not to mention you end up with a TON of dependencies.

Vue doesn't have a big API. I learned the entire of vue in an afternoon.

It took me 2 weeks to understand react, and much more to actually write decent code with it. Practically, react is very unproductive without something like create-react-app because you have to take so many decisions about it for every new project. Simple things like placing a setInterval()/clearInterval() at the right place, or conditionally settings classes on stuff is not straightforward, anything more complicated must be meticulously though.

Because of this, when I give a training in react and one in Vue, the people from the vue training will immediately be 3 times more productive: their projects move faster, it rarely hit a read block later. I also get way, way less questions in the vue training.

Let's not confuse "barebone API" and "easy API". It's not the same.


> It took me 2 weeks to understand react, and much more to actually write decent code with it. Practically, react is very unproductive without something like create-react-app because you have to take so many decisions about it for every new project.

I won't argue that bootstrapping a React project is more complicated than a Vue project. I will argue that React's developer ergonomics are much better.

> Everybody has a boilerplate one of course. Nothing is standardized, so the ecosystem is not reusable.

Not sure what you mean. We use CRA at my company and I can comfortably drop into projects I've never seen before with complete confidence.

> Simple things like placing a setInterval()/clearInterval() at the right place

This doesn't make sense to me. The pattern for setting/clearing an interval with the class-based React API is identical to Vue. With React's hook API it becomes even easier.

> or conditionally settings classes on stuff is not straightforward

How? It's just JavaScript, write a conditional. This is exactly what I'm talking about: you don't need to know how to conditionally set a class in React, you just need to know how to conditionally set a value in JavaScript. I get really tired of the "how do I do task X in Framework Y". I want to ask that question as few times as possible.

My go-to example to explain why I find React so much simpler is Vue's slots. It's an entire API that many people find confusing to replicate something that comes for free in React.


> I will argue that React's developer ergonomics are much better.

Depends for what. For industrial size project, a little, because of the better typescript support. But that's it. You have the same vscode and browser extensions otherwise.

> we use CRA at my company and I can comfortably drop into projects I've never seen before with complete confidence.

First, on this part I'm talking about JS in general. Only a minority of projects use react.

Of course, not all projects use CRA. Many projects use different versions of react with different things you can do with it. Many projects will chose different convention for adapting components, passing children rounds, talking to parent, binding function, etc.

And I _never_ see two react projects with the same me directory tree. There is no strong convention on it.

Then you must chose.

One project is using an inhouse store with useContext, on other use manual redux with that convention, on use redux with that other convention, one use redux-toolkit, one use manual mobx with that convention, one use mobx react, etc. None of them work the same. None of them integrated the same.

And that's just for one lib. One project as many of such libs, all integrated manually.

And yet, the CRA experience is supposed to be one of the best integration you can have.

When you come from another world like Ruby or Python, it's a mad house.

In fact, I'll argue than only experienced programmers manage to get a consistent experience in the JS world.

> Simple things like placing a setInterval()/clearInterval() at the right place

Nope, in react you can use lifecycle OR hooks. You have to choose. And they don't work the same at all.

In vue, for a simple hello world, you can even place the setInterval outside of the component and hapily modify the model, it will update. You don't have to figure out the lifecycle for small app, only for a reusable component.

>How? It's just JavaScript, write a conditional. This is exactly what I'm talking about: you don't need to know how to conditionally set a class in React, you just need to know how to conditionally set a value in JavaScript.

C strings are just an arrays of char, so you don't have to learn those pesky high level string objects in those modern language with all their new fancy API.

> My go-to example to explain why I find React so much simpler is Vue's slots. It's an entire API that many people find confusing to replicate something that comes for free in React.

In both case the user will google "how to get a reference on children components". There is now way you can guess that it's passed as props.

And then, you will want to have several children at different places. And now the illusion breaks, because props.children doesn't work, you have to manually pass each children as props, and you can use them nested as before. And because it's not a "feature", but a convention, you have to know that you need to do that for components that use it. So it's no more natural that slots.

While in vue, you still use slots, you just give them names. The feature is congruent from the simple use case, to the advanced one.

So maybe for the simple case it took 5 minutes in react, and 6 in vue, and the same time for the complex case. For a rarely used feature.


>no Django/RoR equivalent in JS

Both angular and ember are pretty close in my opinion.


They are client side, not server side.

They have a very, very limited scope.

They don't have to deal with the DB, the authentication, the permissions, the deployment, the creation of a REST API, the migration, the mix of several run times, uploads, logging, sending emails, session management, etc.

And yet.

Their support for i18n, validation, routing, caching, pagination, data formating and presentation - what they should be good at - is abysmal compared to what you can do with django/ror.

The only thing they are better at is templating and creating a hierarchy of components. Which is the least they can do given they are literally there to render the UI.


Ah, for some reason I thought you meant clientside alternatives. For backend, there is sails and now nestjs.


Unfortunately, javascript web frameworks build on top of the javascript APIs browsers expose.

If you're starting from a set of APIs that are too complex for someone to keep in their head, it's hard to end up with a much simpler API.

Especially since people do use a large portion of the web's APIs.

For example, "prevent", the thing in the parent comment, is needed if you use javascript to submit your forms, but isn't needed if you have a form that is expected to be submit by the normal browser mechanism.

Webframeworks rarely are prescriptive to the point where they can default in one direction or the other on that point.. and thus we end up with another option.

That repeats many times over and we end up with a large API surface.


Yes but if everybody does that, the only thing that will remain in the history will be unchallenged inflammatory claims.

Which will lead most people passing by to consider that the topic is mostly driven from the point of view of this minority.

This is why we hear a lot about the SJW, anti-vax, the flat earther and so on these days: they make a lot of noise online, even if IRL we never see them because there are so few of them.

This is also why we can see extreme political point of views rising, because people are embolden to join in, reading mass of unchallenged content, pandering to their fear. IRL, they may not, it would not be socially acceptable and the barrier to entry would be bigger.


People generally don't say inflammatory things because they're inherently evil. They're scared, or mad, or have things going on in their life. Arguing online won't change that. Conversely, fixing those things may make trolling less appealing.

https://www.goodreads.com/quotes/632474-i-have-a-foreboding-...


It's possible to implement the concept in asyncio as well, just not enforce it for dependancies due to ensure_future().

See ayo for a very rougth draft of the idea: https://github.com/Tygs/ayo


There is a lot of overlap between wormhole and webrtc thought, and using it as a channel has been on the road map for a long time.

So maybe people knowledgeable enough to build it just waited for it, or went to apply PAKE like rdv on top of webrtc.


If everyone will get it as you say, the elders will too.


Yes, it isn't even about protecting the old. The sole purpose of the quarantines and self distancing is to avoid the healthcare system to collapse. Corona will become a constant companion for mankind, unless people get, one day, broadly vaxxed. But since we can't get people to vax for far worse diseases this won't happen.


Agreeing with your point: there is only one human virus thought to have been successfully totally eradicated: smallpox, which plagued humanity from ancient history until the late 1970s.

But herd immunity due to widespread (if imperfect) vaccination gets you much of the way there. Assuming flu vaccines continue to work, there probably can't be flu outbreaks that kill tens of millions of people as there have been in the past.


Yes, they almost own the entire JS ecosystem at this point.

They lost a decade of battles for the web, but it seems they just found a way to get back in the fight.

Now at the IE 6 times, that meant monopoly, and it was terrible news.

But today, it means more competition between the giants, which is very good for us.


One could argue that the IE6 of our times is Google Chrome at this point..


Safari.


Care to explain? Safari has one of the highest standards compliance of any modern browser [0], which IE famously did not.

It has been argued with various success [1] that Chrome is the new I.E., due to "Chrome exclusive" web standards.

[0]: https://html5test.com/compare/browser/safari-11.2/chrome-30/...

[1]: https://news.ycombinator.com/item?id=16070595


I think the honest truth is that a lot of developers see Safari similarly to IE because Firefox and Chrome are quick to jump on and ship new features and "if only Safari kept up" they could be used "everywhere". Combined with the fact that iOS is large enough that you can't just drop Safari support and tell them to use Chrome.

It's a weird world where webdevs apparently ideally just want everyone on the 6 second old version version of Chrome. I totally get it -- it's an absolutely rational stance but it feels a lot like how devs felt about IE6 at the beginning.


You're right, IE6 was amazing at the time. It made a ton of things possible that previously hadn't been, and the standards bodies were lagging behind it. Had MS actually kept updating IE6 and kept it ahead of the standards, the standards would never have mattered, and we'd never have developed this sick taste for IE. No one hated that they had a monopoly, we hated that they had a stagnant monopoly.


Those of us that were using non-MS OSes like Linux or FreeBSD or Solaris back then hated it that sites were made to work correctly only on IE.


Your comment just triggered the box model. Which is what I call my flashbacks about when hasLayout was true or not.


If you are going to compare browsers make sure you aren't comparing against a version of Chrome from 2013.

Here is the correct comparison: https://html5test.com/compare/browser/safari-11.2/chrome-68/...

Which clearly shows its the worst of the bunch.

Edit: Also just noticed, the latest Chrome version that the site has is 68. We're currently on 80+


A more up-to-date, although not complete, comparison is available here: https://caniuse.com/#compare=firefox+74,chrome+80,safari+13


I've worked with projects that used iframes in safari. It had some of the weirdest bugs. Some random times it didn't render changes to the DOM. Sometimes when clicking input fields it would focus the surrounding iframe element.

A webview in iOS could sometimes crash system wide. Not enough to restart the app. You'd have to restart the device.

Felt like a sitcom when I had to ask customers if they'd tried turning it off and on again.


Chrome is pushing version 80, I'm not sure why that website is using a version from seven years ago…


Safari is way behind Chrome and Firefox on web features and has all kinds of proprietary rules on existing implementations.

It's not even required or the default install on any OS. And it has rapid updates that constantly test new features and improve performance and security.

Any "exclusive" features are just early testing for later standardization. It's Safari that's lagging in implementing them.


Not for Javascript it doesn't.

Plus because it's tied to the OS and the phone determines the maximum OS you end up with a bunch of users stuck on ancient and buggy versions.

This is to say nothing about the remote debugger purposefully locking you out of older versions for no reason to make debugging them harder.


Want to try something fun? Install any browser in iOS and do a test. Then do the same test with Safari. Now ponder why they are exactly the same no matter which browser you install.


If you're referencing Apple's mandate that WebKit be used as the engine for all iOS web rendering, then yes, that's a poor policy ostensibly made in the name of security. Not sure if that's what your point is, though.


Can you imagine how much legal trouble microsoft would be in if they blocked alternative browsers in windows? Simply providing a single default was too much.


I also can't run Safari on my Windows or Linux machines.


Safari doesn’t have the market share that IE6 had, though. Chrome has.


I think it's important to remember that IE6 was an amazing browser when it was first released.

The problem is that it was left to stagnate after Microsoft won.


My first though was "oh, another covid-19 article". The human mind is funny.


We're all on timeout and everything is cancelled. Makes sense.


sudo killall -19


Same exact thought I had.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: