4 ms·
There's a joke that is roughly "Python is not the best language for any particular task, but is nearly always the second best language for that task" - it's a
by zdw 3y ago
There's a joke that is roughly "Python is not the best language for any particular task, but is nearly always the second best language for that task" - it's a jack of all trades language.
Because of this, lots of people learned Python, and then applied it in many different areas, and it just became more prevalent and useful.
- agumonkey 3y agoyeah it's a good enough especially to start poking around 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
- earthboundkid 3y agoI think that's part of the answer. Python has multiple independent communities of use: web, data science, ML, devops. Most languages only have one or two ecosystems of use. 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.
- 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> Python is not the best language for any particular task, but is nearly always the second best language for that task 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.
- mananaysiempre 3y ago> Python is not the best language for any particular task, but is nearly always the second best language for that task 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.
- hk1337 3y agoI have always thought it was a good prototyping language. You can get something working fast then rewrite it in a better language later.
- racl101 3y agoDefinitely a jack of all trades language. 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.