24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions
https://www.bitecode.dev/
Email: contact at bitecode.dev
comment 6y ago · link · parent
- never become statically typed
- never make the type hints mandatory
- never enforce the type hints at run time
Python is jokingly said to be "the second best language for most things". To achieve this, it has to be able to be decent for many different purposes such as setuping machine learning models, scripting SIG system, doing test automation, powering a web site, provisioning linux servers, scrapping web page, batch renaming files and teaching code, analyzing numbers from a hdf5 file, being the client to a database/ftp/ssh/imap system.
It means it can't just be purely functional/OOP/imperative, be must borrow from each paradigm. Be statically typed or not, but gives features from both. Etc.
Because you don't want type hints when you are in jupyter or scripting your linux box. But you may want it when your Saas reach 3 millions lines.
comment 6y ago · link · parent
You can still write python programs without them.
You can add them only partially.
You can also add them later.
Python stays Python.
MonkeyType lets you take a code base that is untyped, or partially typed, for historical or because it was not worth it at the time, and turn it into a fully typed project quickly.
It makes the transition between the exploration phase into the industrial phase much easier.
For me, it's kinda fantastic to be able to fiddle with a design, changing my mind again and again, without having to fight the type system, then once things are settled, add an additional safety net on top.
It's also very reassuring knowing I can just hack things, knowing that later on, if I want to take it to the next level, I have the option to change my mind about type hints.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
See ayo for a very rougth draft of the idea: https://github.com/Tygs/ayo
comment 6y ago · link · parent
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.
comment 6y ago · link · parent
It also fits nicely into the context manager pattern.
Besides, remember exceptions are cheap in python. So cheap that for loops are basically syntaxic sugar for a try/catch.
comment 6y ago · link · parent
While in Python, when you see a class, you just know the methods are mostly about "self".
It helps making sense of the code immensely.
comment 6y ago · link · parent
I dislike that.
When I see a class, I expect it exists because there is a central state around which the methods revolve, and are meant to expose or change it.
When I see a function, I expect it to be side effect free.
Sure you can use any paradigm to make any program, but I use paradigms, just like I use design patterns, to communicate intent. Solving the problem is half the battle. In a way, coding style is documentation. I think we should build boring API, and only use cleverness to find solutions, or make the API easier to use and more elegant.
I worked once on a code base that broke a lot of implicit expectations. Like, it could add objects in a registry when you instantiated some classes, get_stuff could set other stuff, do_stuff would not do stuff but actually_do_stuff would, etc.
It was a nightmare to work with, because anything could happen anywhere. You had to look at the code every single time and keep the whole system in your head, which had 900k lines of highly technical code.
comment 6y ago · link · parent
Don't act, and you'll get a messup economy because of the panic and the sick people.
Act, and you'll get a messup economy because of the panic and the sick people, and the cost of tests+quarantines+curfew. Less people dead is the ethic thing to do, but power is not about morality.
comment 6y ago · link · parent
I see a lot of what you mention on online mediums.
But it's usually quite different than what's really happening IRL.
People love to play the panic game online, but I've seen only quiet order around me.
Yesterday, my entire neighborhood has been evacuated because of a bomb, we were all grouped in an hospital, where we were questioned about possible fever.
In airports, I see people wearing masks, facing cancelled flights. I see stores with huge queues to buy stock of food.
It all happens in a calm and civil manner.
Maybe I'm optimistic, but I'm nicely surprised by the way people act right now, despite all the blame we want to place.
comment 6y ago · link · parent
Besides, it's a lose/lose proposition for the gov anyway.
If they do act, people will blame them for the cost of the action.
If they don't, people will blame then for the cost of not acting.
Nobody will pat them on the back, except a few intellectuals, for acting.
In fact, economically, the virus spreading is an opportunity to fire people you couldn't fire before, get rid of an old population costing money and have an excuse for a lot of things like passing certain types of law. People will not focus on that, their attention is elsewhere, and you can always invoke the circumstances if they do.
We have created a system in which it's not in the interest of the gov to solve the problem. And in which the population lives in a way that makes it hard to do the right thing by themselves.
comment 6y ago · link · parent
In France you can only get pills dosed at a very small 800 IU (international unit, see: http://www.nafwa.org/vitamind.php) without prescription, but in the US, you'll find some bottles dosing a single pill up to 10 000 IU.
The pills look all the same no matter the dose. They are minuscule yellow balls, but they can be very concentrated.
So "take a lot of Vitamin D" doesn't mean "take a lot of pills". Target an amount of IU, and take exactly what you need for that.
Vitamin D has been found toxic if you take more than 60 000 IU/day for 3 month. You'd have to be quite heavy in your dosing to reach this, but I'd rather share the info.
There is no overdose possible if you get it from the natural source: exposition from the sun. And it's healthier. But as a geek you may see the light of your monitor much more than the one from the sun, and D supplements are incredibly cheap for the huge benefit in energy and mood they provide in the winter.
I take 5 000 UI/day (as Cholecalciferol, so D3), and my doctor already thinks it's a lot since the daily recommended dose here is 200 IU.