4 ms·
> Python is not the best language for any particular task Python basically solved this problem by wrapping around C code that's far more performant, but still
by screye 3y ago
> Python is not the best language for any particular task
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 https://twitter.com/iammemeloper/status/1692901551558320254
Amen
- The_Colonel 3y ago> Python basically solved this problem by wrapping around C code 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.
- memefrog 3y agoIt is not hard to write C. It is hard to write large safe multi-developer C programs with complex object lifetimes. But if you are just writing an inner loop in a CPython extension it is easy.
- tomn 3y agoMaybe so, but it's not like there are a lot of languages around that are as expressive, flexible and easy to learn as python, but as fast as C. 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.
- The_Colonel 3y ago> Maybe so, but it's not like there are a lot of languages around that are as expressive, flexible and easy to learn as python, but as fast as C. 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.
- tomn 3y ago>There are several languages on the JVM which are that or better. As fast as C, no... 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.
- The_Colonel 3y ago> Like what? None of the ones i know of meet the "expressive, flexible and easy to learn as python" test. 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.
- 3y ago
- bee_rider 3y agoIt is a great solution. If you write Python, nobody will mistake it for fast code, it stays where it belongs. 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.
- The_Colonel 3y agoThese mental excuses are pretty funny :-D 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.