Energy Efficient Programming Languages
Every #SoftwareEngineer has heard this question before: Which programming language is “the best”? What usually follows is a heated discussion that is entertaining at best and totally pointless at worst. It’s like asking a group of random people for their favorite food, car brand or travel destination. Context and personal tastes matter a lot, it’s very subjective.
However, it gets interesting when you are able to measure things with objective criteria. I recently stumbled across an interesting research paper: “Energy Efficiency across Programming Languages” from Rui Pereira et. al. While performance benchmarks for execution speed and memory consumption are nothing new, energy consumption is usually not considered at the language level but rather at the hardware or algorithm level.
Here are some of the things I learned from studying this great paper:
- While compiled languages are usually the fastest and most energy-efficient, some virtual machine languages can compete with them. For example, C has an energy score of 1.00 at rank 1, and Java has an energy score of 1.98 at rank 5, which is the highest of all examined languages that do not compile to native code. Yes, you heard that right. Good old Java is very efficient, especially when you consider all the inherent abstractions.
- Interpreted languages are usually way less energy efficient than their compiled competitors and VM-based colleagues. Dart and JavaScript are still pretty decent with a score of 3.83 and 4.45. Ruby and Python are significantly more expensive at energy scores of 69.91 and 75.88 (lower scores indicate less power consumption).
- Energy efficiency tends to correlate with execution speed (although not always). This is not true for memory consumption, though. The ranking for peak memory consumption is quite different from the ranking for efficiency and execution time. As an example, Pascal and Go are ranked highest, even in front of C and Rust.
Special thanks to Josh Long who showed this paper in his talk at Devoxx Belgium “Bootiful Spring Boot 3”. I highly recommend his talk to anyone interested in Java, Spring or just his personal humor.
I would love to see research on the topic of developer productivity combined it with other efficiency metrics. I have a strong feeling that languages like Python and Ruby would score very highly on a productivity scale. This is probably less true for languages like C and C++, which are great for machines but less productive for humans.
What is your opinion about this?
You can find the original research paper here: https://greenlab.di.uminho.pt/wp-content/uploads/2017/09/paperSLE.pdf
Note: You can also find this episode on YouTube and Spotify.
#SoftwareEngineering , #Programming, #Efficiency , #Java, #Golang