I like many of your points, but your comment is facetious.
You said it yourself, “it’s good for someone trying to bang out scripts”… and that’s it, that’s the main point, that’s the purpose of python. I will argue over my dead body that python is a trillion times better than sh/bash/zsh/fish/bat/powershell/whatever for writing scripts in all aspects except availability and if that’s a concern, the only options are the old Unix shell and bat (even with powershell you never know if you are stuck ps 5 or can use ps 7).
I have a python script running 24/7 on a raspberry that listens on some mqtt topics and reacts accordingly asynchronously. It uses like 15kiB (literally less than 4 pages) of ram mostly for the interpreter, and it’s plenty responsive. It uses about two minutes of CPU time a day. I could have written it in rust or go, I know enough of both to do it, it would have been faster and more efficient, but it would have taken three times the time to write, and it would have been a bitch to modify, I could have done it in C and it would have been even worse. For that little extra efficiency it makes no sense.
You argue it has no place in mainstream software, but that’s not really a matter of python, more a matter of bad software engineers. Ok, cool that you recognise the issue, but I’d rather you went after the million people shipping a full browser in every GUI application, than to the guys wasting 10 kiB of your ram to run python. And even in that case, it’s not an issue of JavaScript, but an issue of bad practices.
P.S. “does one thing well” is a smokescreen to hide doing less stuff, you shouldn’t base your whole design philosophy on a quote from the 70s. That is the kind of shit SystemD hater shout, while running a display server that also manages input, opengl, a widget toolkit, remote desktop, and the entire printer stack. The more a high profile tool does, the less your janky glue code scripts need to do.
Jarix@lemmy.world 5 months ago
For us ludite lurkers who couldn’t figure it out from context alone, which one is the interpreted language? I got lost on that detail lol
DarkAri@lemmy.blahaj.zone 5 months ago
Interpreted languages are languages that are compiled at run time. Compiled languages are compiled into binary by a compiler and then distributed as binaries.
Basically with interpreted languages, there is huge overhead because the code has to be compiled (turned into machine code) as the program is running. This is why games and operating systems are written in C but people learn how to write Python and Java in their college classes. Interpreted languages are often much easier to learn then C and cross platform, but C is fast and powerful.
squaresinger@lemmy.world 5 months ago
Technically speaking, interpreted languages aren’t compiled at all. That was the original definition.
Nowadays, there’s hardly any clasically interpreted language. All major interpreted languages compile to bytecode, which is then run via a kind of VM that interprets that language. But many languages (like Java) go even farther and compile that bytecode into native machine code at runtime.
Being interpreted, though, is an implementation feature, not a language feature. So, for example, if you use CPython, Python is compiled into bytecode when you first run a script. The bytecode is then stored and used the next time you run the same script as long as it hasn’t been changed in the meantime. You can also force the compilation to bytecode and only ship the bytecode.
But if you use Pypy instead of CPython, it is a regular compiler that compiles into native machine code. No bytecode and/or interpretation in the process at all. This increases the performance of pure Python by around 5x, according to some benchmarks.
But that kind of benchmarking is kinda flawed anyway because most real-life programs don’t only use pure Python.
There’s a thing called Cython (not to be confused with the Python interpreter called CPython), which allows C-Code to be called from Python. Cython is used by almost all modules that contain performance-critical code, and it’s just as fast as using C directly.
In most applications, you have a concept called “hot code”. That’s specific code paths that take up the vast majority of the code execution time (usually 95+% of the time are spent on just a few code paths). So when optimizing Python code, you figure out which these are and then you use Cython to implement them in C (or use a 3rd party module that already does that).
Then you use Python only as a “glue code” that covers all the low-usage code.
In that use case, Python is only marginally slower than C.
Slow Python programs are usually an issue of optimization, not an issue of the language itself.
DarkAri@lemmy.blahaj.zone 5 months ago
Python has come a long way in recent years, I remember when android switched to an ahead of time compiler for its java.
I really like lemmy. I usually learn something everyday. Thxs for that.
My current project is trying to create a cool fork of mobian for the pinephone with overclocks and some other stuff, right now I’m editing the debt trees to get about 50% more performance for roughly the same battery life, out of the pinephone.
With some other things, a bigger battery, and a custom modem firmware that can downclock the CPU in it, I’m getting 2% battery drain per hour with the screen off.
Jarix@lemmy.world 5 months ago
Love you. Thank you
DarkAri@lemmy.blahaj.zone 5 months ago
Interpreted languages are very optimized these days, and get much closer to native C performance.
Also thanks internet stranger. <3
captain_aggravated@sh.itjust.works 5 months ago
Python is interpreted.