also I just realized that Brazil did NOT make a programming language entirely in Spanish and call it “Si” and that my professor was making a joke about C… god damn it
this post is probably too nieche but I feel like Lemmy is nerdy enough that enough people will get it lol
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
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.
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.
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 device 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.
Yeah, stuff improves a lot, but prejudices often stay the same. Java is really fast nowadays. That didn’t use to be the case.
Yeah, with a lot of work, really cool things can be done.
I have several reasons for not liking java. One is that it uses a garbage collector but another the real reason, besides that it’s often slower than C to write in because it puts many constraints on you like forcing you into an object oriented paradigm. Python I don’t like because it forces you to format your code in a certain way which I don’t really like. I like the freedom of C. It has basically everything I like in a language, it’s fast, one of the fastest, it not safe. I hate safety, my trigger finger is my safety, and it has wide support and examples to draw from, but my favorite thing is probably how powerful and feature complete it is. You can do nearly anything with C. I have been using it since before I was a teenager and I still don’t know how many of its features work because I’ve never had a use for them. Things like templates and stuff. Also sometimes it’s just really useful to do things like create your own data types and stuff. Cast different types as strings or something. I like being able to write functional code as well as Op code along side each other. I like to build up most of my systems from scratch for performance reasons, like file handling because I do game programming usually. I understand many people dislike these things about C but I always rather have freedom and power and maturity for the types of things I like to do.
Love you. Thank you
Interpreted languages are very optimized these days, and get much closer to native C performance.
Also thanks internet stranger. <3
Python is interpreted.