Because of this, lots of people learned Python, and then applied it in many different areas, and it just became more prevalent and useful.
Because of this, lots of people learned Python, and then applied it in many different areas, and it just became more prevalent and useful.
I think the other part of Python's success compared to JS is a better story about C integration. Python itself is just a series of macros to make C nicer to use, which meant the existing C/C++ ecosystem was relatively easy to integrate. And then the sci-py world also brought in Fortran. JS is huge on the backend web, but it hasn't spread into other ecosystems nearly as much because the C integration story isn't as good.
Python basically solved this problem by wrapping around C code that's far more performant, but still exceptionally simple to leverage due to python's simple syntax. LlamaCpp has C++ in its name, yet its most popular platform is python. So for certain applications, python because the undisputed #1. Because it was C in disguise, with better usability.
With parallelization, Python having 100x slower loops became an old problem. 2023's coding paradigm is "if you're using loops, you're doing it wrong." People love complaining about pandas, but Dask solved all the single-core problems in 2021.
> https://twitter.com/iammemeloper/status/1692901551558320254
Amen
I would rather call it a work-around. Having to switch to a vastly different language to get halfway decent performance is hardly a good solution.
It's not a rare thing in normal applications that you need to have some routine fast and there's no pre-built C solution for it.
JS is probably the closest, but not because of superior language design -- people with money wanted it to be faster, so it is.
Also, the choice is not just python, or writing a module in C -- there's numba and cython, various python compilers, pypy and cffi.
There are several languages on the JVM which are that or better. As fast as C, no, but JVM is considered fast enough for a lot of applications where performance matters.
> JS is probably the closest, but not because of superior language design
There's this myth that Python as a language is superior to JS. In reality both have their long history and warts. JS/V8 is just much faster.
For me personally, JS is a much more ergonomic language than Python.
Like what? None of the ones i know of meet the "expressive, flexible and easy to learn as python" test.
> There's this myth that Python as a language is superior to JS. In reality both have their long history and warts. JS/V8 is just much faster.
I never said anything about being better or worse, just that as far as i know there's nothing about JS which makes it much easier to optimise than python.
I'm not arguing that python is the best thing to use for everything, or that there are no faster languages; that clearly isn't the case.
The topic is "why is python popular", you're arguing that it's too slow and it's too much effort to speed up code, while I'm arguing that there are no languages which are faster, and don't give up some of the things that made python popular in the first place.
Kotlin is IMHO the best of the bunch, but Groovy might be the most similar to Python.
> I'm arguing that there are no languages which are faster, and don't give up some of the things that made python popular in the first place.
Python has some advantages for scripting - it's almost ubiquitous on Linux distros. But for application development, I don't think it's better than other platforms.
> I don't think it's better than other platforms
I think we're done here.
JavaScript for example is much worse, because people are convinced it can be fast for some reason, and keep trying to write nested loops in it.
One problem with this is that you expect a perfect dichotomy where you can isolate code which can be slow and which can be fast. But for a lot of code it's not easy to say in advance (pre-mature optimization plays a role too) and/or it's somewhere in the middle.
We have a big Java application with hundreds of thousands lines of code. Its performance is so-so. But if you look at the profiler, there isn't a clearly responsible module/method (all obviously slow methods have been already optimized). Now it's a death by a thousand cuts. Making it in Python would make it unacceptably slow with no obvious places which could be converted into C. Writing the whole thing in C would make it a much more complex endeavor.
Pointing out any problem where speed is the difference between working and unusable—e.g. ray tracing—is probably too cheap a shot, as it’s not like Ruby or Perl are any better in that regard, and LuaJIT came too late to be relevant to the current question.
One range of problems where I’ve found Python (unextended by a code generator) to be surprisingly awful, though, is everywhere the ML style of algebraic datatypes + pattern matching is natural: compilers, basically, all the way down to a regex engine. There’s just no comparison.
Maybe things have changed now that `match` exists? I’ve not yet had the time to try, even if the double indentation doesn’t make me hopeful.
And when you get older, and you care more about solving problems than about trying new things, and you've got more responsibilities in life and lack the time to devote to learning new language / technology du jour, then knowing and using Python becomes so handy.
If it is indeed the 2nd best language for the job, it is still a decent choice if you get to solve the problem.
many accounts of people dropping other languages with better perf or semantics to use python as a prototyping++ tool
it was a trend in many dynlangs (php and others) where you'd write the core in it and drop to C for hot loops
python is better than php, it has some metaprogramming (hello CLOS) to mold it syntactically wise, good enough stdlib, low enough semantic warts ..
than and numpy/pandas for non sweng crowds
The "second best language" is false, it's just usable for a wide variety of tasks. Just like many other languages, but specifically not Ruby.