We have a time in which concern for both ecological sustainability and the price of electricity (even more so now, given the current energy crisis) has led us to ask ourselves how much our house, our road routes or the websites we visit consume.
But have we ever wondered which programming language is more sustainable? Certainly, It is not a piece of information that we are used to asking ourselves when choosing between C # and Java, between Rust or Pascal, or between JavaScript and Python, for example.
Factors such as low / high level, amount of documentation available or multiplatform availability yes, but electricity expense? … It seems weird to even consider it.
However, lo and behold, a few years ago six researchers from Portuguese universities set out to investigate the power consumption, runtime, and memory usage of up to 27 of the most popular programming languages, later presenting his research at the International Conference on Software Language Engineering 2017.
Its creators, in addition, have been updating the methodology and versions of the languages used, the last review of the study having been published in May of this year, so the results are still relevant to ‘green’ concerned programmers:
“We monitor the performance of these languages using ten different programming problems“, they explain in the ‘paper’, referring to the standard algorithms compiled by the Computer Language Benchmarks Game project, dedicated to implementing algorithms in different languages.
In addition, to measure power consumption, the team turned to Intel’s RAPL (Running Average Power Limit) tool, capable of providing highly accurate power consumption estimates.
“Our results show interesting findings, such as slower / faster languages that consume less / more power, and how memory usage influences power consumption. We show how to use our results to support software engineers in deciding. why language to choose when energy efficiency is a concern “.
The researchers recall that, since energy is not consumed at a constant rate, it is not enough to resort to the formula ‘Energy = Time x Power’
The programmer career in 2017 and in the future (with Javier Santana)
The five fastest languages, also the greenest
Most of us would take for granted that an application that runs faster will consume less power. But this not always true, since various physical factors influence, which is reflected in the disparity in the rankings of each of the three criteria evaluated.
However, there is a coincidence between the five fastest languages and the five with the lowest energy consumption, rising C with the position of ‘Greenest programming language’, closely followed by Rust:
- C
- Rust
- C ++
- Ada
- Java