by The_Colonel · 3y ago · 0 comments
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.
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.