What Are the Greenest Programming Languages?
Programming languages and energy consumption

Learning a programming language and becoming an expert in that language is not easy. Although most developers know several programming languages, we only consider ourselves experts in one or two.
When deciding on a new programming language, we usually take into account things like its syntax, its learning curve, its documentation, or whether it is widely used or not.
But have we ever wondered which programming language is more sustainable and consumes less energy?
This is not a fact that we are used to considering when choosing between JavaScript, Python, Java, C#, or any other language.
However, a few years ago, some Portuguese researchers set out to investigate the energy consumption of up to 27 of today’s most popular programming languages, subsequently presenting their research at the International Conference on Software Language Engineering 2017.
These results are still valid in 2021 because they were updated this same year.
Energy Efficiency across Programming Languages
Abstract of the paper:
“This paper presents a study of the runtime, memory usage, and energy consumption of twenty-seven well-known software languages. We monitor the performance of such languages using ten different programming problems, expressed in each of the languages. Our results show interesting findings, such as slower/faster languages consuming less/more energy, and how memory usage influences energy consumption. We show how to use our results to provide software engineers support to decide which language to use when energy efficiency is a concern.”
According to the “paper,” in this study, they monitored the performance of these languages using different programming problems for which they used different algorithms compiled by the “Computer Language Benchmarks Game” project, dedicated to implementing algorithms in different languages.
The team used Intel’s Running Average Power Limit (RAPL) tool to measure power consumption, which can provide very accurate power consumption estimates.
The research shows that several factors influence energy consumption, as expected. The speed at which they are executed in the energy consumption is usually decisive, but not always the one that runs the fastest is the one that consumes the least energy as other factors enter into the power consumption equation besides speed, as the memory usage.
Ranking
In this ranking, we can see the “greenest” and most efficient languages are: C, C+, Rust, and Java, although this last one shoots the memory usage.
From the Paper: Normalized global results for Energy, Time, and Memory.
Energy
From this table, it is worth noting that C, C++and Java are among the languages that consume the least energy. On the other hand, JavaScript consumes almost twice as much as Java and four times what C consumes. As an interpreted language, Python needs more time to execute and is, therefore, one of the least “green” languages, occupying the position of those that consume the most energy.

Time
The results are similar to the energy expenditure; the faster a programming language is, the less energy it expends.

Memory
In terms of memory consumption, we see how Java has become one of the most memory-consuming languages along with JavaScript.

Conclusion
Although this study may seem curious and without much practical application, it may help design better and more efficient programming languages. Also, we can use this new parameter in our equation when choosing a programing language.
This parameter can no longer be ignored in the future or almost the present; besides, the fastest languages are generally also the most environmentally friendly.
Thanks to these Portuguese researchers, we now have another parameter to choose a programming language and a new weapon to help the planet in a computerized world where millions of machines are continuously running code.
If you enjoyed this article, consider subscribing to Medium through my profile. Thank you!
References
https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game






