5 ms·
I continue to believe that python is only still popular for the ecosystem effect. Students are taught it, a bunch of libraries were written for it, now everyone
by internetter 1y ago
I continue to believe that python is only still popular for the ecosystem effect. Students are taught it, a bunch of libraries were written for it, now everyone keeps using it.
But its syntactically weak? Python itself is slow? pip is awful (although uv is pretty good). Sometimes I am forced to write python because the packages I need are written for it but I always hate it.
- paulddraper 1y agoIt's syntactically strong. AFAIK, it's the preferred language for lots of leetcode, e.g. Advent of Code. The practical expressivity and speed of dev is strong.
- gloxkiqcza 1y agoWell it’s as close to executable pseudocode as it gets, which I would say is both a positive and a negative.
- internetter 1y agoJust for example, the lack of explicit variable defs. I create a variable and update it later. I rename the variable but forget to change it where it is updated. No errors produced in the IDE because the place where it is updated is now just creating the variable instead so all the references still work. `let` is a good keyword. It drives me crazy how everything just... blocks. Parallelization is a disaster. I won't comment much on indentation. All the string formatting syntaxes is crazy. Private names managed by `_`. The type system still mostly sucks. Ect ect. In my experience it is alright to write short scripts but complexity very quickly balloons and python projects are very often unwieldy. I would write a script in python, but only if I was positive I would never need to run or edit it again. Which is very rarely the case.
- BeetleB 1y ago> No errors produced in the IDE because the place where it is updated is now just creating the variable instead so all the references still work. `let` is a good keyword. I too would prefer let. But the number of times what you mentioned has bitten me in almost 20 years of programming Python can be counted on in one hand. And these days, just use the "rename" feature in your IDE!
- paulddraper 1y ago> Just for example, the lack of explicit variable defs This is an extraordinarly common feature among scripting languages. In fact, JS is really the odd duck out. Shell, Ruby, Lua, Perl, R, AWK, etc > I rename the variable but forget to change it where it is updated. Type checkers will catch this. (And IDEs will help.) You don't have to use type checking of course, though it sounds like you like to. > It drives me crazy how everything just... blocks. There are comparatively few languages that primarily rely on cooperative multi-threading. > All the string formatting syntaxes is crazy. f"Hi my name is {name}" --- FWIW, you just don't like most scripting languages. Which is fine, but it goes far beyond Python. Python, Perl, Ruby, PHP, Lua, Tcl
- 01HNNWZ0MV43FF 1y agoJavaScript is like that. C++ was kinda like that. I think "Popularity among novices" is the only thing that determines whether a language will succeed or fail in the long term (say, 20 years)
- internetter 1y ago> JavaScript is like that. JavaScript has gotten drastically better, especially since ES6. The lack of venvs alone is such a breath of fresh air. The baseline typing sucks more than python, but typescript is so much better. It still suffers from legacy but the world has mostly moved on and I don't see beginners learning legacy stuff much anymore. Modern javascript is amazing. I do my work in Elysia, Kysely (holy crap the python database situation is awful) and everything just works and catches tons of errors.
- itsnowandnever 1y agoI treat it pretty much like bash. it's good for scripts. and it's great for serverless tasks like running as an AWS lambda. if you want to run some simple script that queries a DB and/or hits an API on a schedule or triggered by an event, Python is arguably the best way to do that because the handler and interpreter work so well together. even still, you'd get better performance with Node. I don't like Python for "applications" as much. I was at a place almost 10 years ago now that had Python "microservices" running in Kubernetes. managing performance and dependencies for Python in production is just unnecessarily futile compared to something like Go that's also very accessible syntactically.
- BeetleB 1y ago> Students are taught it, a bunch of libraries were written for it, now everyone keeps using it. This is revisionism. When I was in school, that's what people would say about C/C++/Java. People like me switched to Python well before it became common to teach it at school. Lots of great libraries were written in it before then as well. I mean, it's really easy to write a library in it than it was in most other languages. It was picked for teaching in schools because it was a decent language, and was already widespread. It's much more useful to teach Python to an average engineering student than C/C++/Java. It became popular because it was easy to learn, and a lot nicer to use than the other big scripting language: Perl. When I was in grad school, I would routinely find non-engineers and non-programmers using it for their work, as well as writing libraries for their peers. There is no way they would have done that in any of the prevailing languages of the time - many of them learned to program while in grad school. It became quite popular amongst linguists. Then NumPy/SciPy became a popular alternative to MATLAB, and once again my peers, who would never write C++ to do their work, were suddenly getting matching speed by using Python. That's how it ended up being the language for ML. So no - the fact that it's taught in schools is not the reason it's used today.
- internetter 1y ago> It became popular because it was easy to learn, and a lot nicer to use than the other big scripting language ... I would routinely find non-engineers and non-programmers using it for their work, as well as writing libraries for their peers. ... many of them learned to program while in grad school. Sure, and this is my argument. It is easy to start out with, which makes it appealing to academics without a CS background. But is this a good thing? Because then these academics without a CS background write monstrous, poorly optimized scripts compounded by a slow language, then use drastically more compute to run their science, and then at the end publish their paper and the scripts they used are very hard to adapt to further research because very rarely are they structured as modules. Just because it is easy to write doesn't mean it is the most appropriate for science. It is not commonly acceptable to publish papers without a standardized format and other conventions. Students put in work to learn how to do it properly. The same should be true for code.
- 1y ago
- janalsncm 1y ago> Python itself is slow Slow is relative. You need to account for the time to write as well, and amortize over the number of times the code is run. For code that is run once, writing time dominates. Writing a Java equivalent of half of the things you can do in Python would be a nightmare.
- internetter 1y ago> For code that is run once, writing time dominates. where "run once" in the sense you describe is really the case has been rare for me. Often these one off scripts need to process data, which involves a loop, and all of the sudden, even if the script is only executed once, it must loop a million times and all of the sudden it is actually really slow and then I must go back and either beat the program into shape (time consuming) or let it execute over days. A third option is rewriting in a different language, and when I choose to do a 1:1 rewrite the time is often comparable to optimizing python, and the code runs faster than even the optimized python would've. Plus, these "one off" scripts often do get rerun, e.g. if more data is acquired. Java is a sort of selective example. I find JavaScript similarly fast to write and it runs much faster.
- janalsncm 1y agoIn practice a lot of heavy lifting performance-dependent code is cython. For example numpy and PyTorch. So Python will definitely be faster than js if you use proper vectorized ops. The vast majority of my Python code is for data exploration and preprocessing which are usually one-offs or need to be run only a couple of times. Or maybe it’s a nightly job that takes 5 minutes instead of 30 seconds in another language, but it doesn’t matter because it’s not user facing. Actual Python execution time very rarely comes into play. If it does and it’s a problem, I will create a pyo3 rust binding.
- internetter 1y agoI think our processing workloads are just different. If you're spending 90% of your compute time in numpy or whatever sure. But for me that wasn't the case, the overhead absolutely was the python.