"Which Programming Languages Use the Least Electricity?"

Sounds like a silly question, but makes for a rather intriguing read!

that was definitely an interesting read!
One thing though that might also make an impact, is how easy it is to use/write code in.
I can imagine that if a language takes a longer time to solve a problem in, you'd also use more energy just from having your computer on while writing it.
Interpreted languages rather than compiled languages are likely to have an advantage here.



Assuming they would turn of the computer when they're done. More likely that time is probably spent adding more power consuming features.

Also, that might become negligible as a programs gets used a lot

@FiXato @fribbledom something that came to mind was: what if applications developed in less efficient languages were ported to C once they were "complete" (lol), so that would be what would executed in perpetuity

@FiXato @fribbledom along these lines, one has to consider that Erlang has many functionalities that in other languages would require third party systems (message queue, distributed database, service discovery and others). Therefore, to be fair, we’d need to consider those as well for each language.

@fribbledom As dumb as it sounds, wouldn't it be natural, that the language, that for any given operation, has the smallest RAM IO delta is the most energy efficient? Of course there will be critical points, where one would have to go into linear optimization, but assuming the same runtime in a non critical situation, there would be less energy cost if a program reserved 100MB of ram, but nearly didn't write anything to it, ...

@fribbledom compared to a program that only reserved 10MB but in exchange IOed like 200MB in and out of ram. So for example if PHP had statically already loaded an efficient regular expression routine, where C/C++ first would have to initialize an object of the same nature, PHP would naturally consume less energy with keeping pre-allocated DRAM cells versus C having to write an object or even a hierarch of objects to RAM for one use, before relequishing the allocated cells again. ...

@fribbledom At least to me the article mostly implies, that the least amount of abstraction on average is more efficient. I'm not commenting here on switching of transistors or fets, because i couldn't find any specifics about those, so I was only looking at the most obvious offender, in this case DRAM.

@fribbledom Oh Rust seems to be quite well off. And I honestly expected Java's Energy usage to be much higher, lol.

I can imagine that if a language takes a longer time to solve a problem in, you'd also use more energy just from having your computer on while writing it.

Only if you run the program a very small number of times before discarding it. For any normal program, and in particular for servers, the energy consumed from developing or compiling the program is negligible compared to the runtime costs.

@fribbledom ah, i wish they'd examined D... i guess it's still too obscure =(

@fribbledom I wonder how compiled Lisp would fare, since it gets translated into C (or C++, I can't remember) and I'm curious about how efficient the translators are.

@fribbledom someone, make something like nodejs, where everythung is JavaScript, but in C ;)

@fribbledom I think if they included compilation cost, C would be even more ahead!

@fribbledom hm, I'm wondering what their methodology for Typescript was. Was the program compiled to JavaScript beforehand, or recompiled each run?

One thing that was not looked over(but I guess it is rather hard to do so) , is the energy needed to write a program. As a general assumption, I would guess writing something in a interpreted language is faster and thus more energy efficient than writing a compiled one.


I'm not sure if that's really an oversight or rather quite intentional.

For any program where energy consumption actually matters, the development time most likely makes up for the tiniest fraction of their consumption. After all we're talking about processes that get deployed not only on hundreds or thousands of machines, but literally millions of devices.

@fribbledom @CedC I dunno, human beings are awfully energy inefficient. Every hour your programmer is stuck waiting for their code to compile is another hour’s wages. It’s not much on a global scale, but when you have not only hundreds or thousands of C++ programmers, but literally millions…

That's what it though at first but after thinking about some real open-source project where the code has to be maintained, review, accepted or rejected and rewrite by numerous people, I started doubting it was neglectable

Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!