The 10 most energy efficient programming languages
In a survey of the energy efficiency of 27 programming languages, C tops the list, and Python was the second most inefficient.
In a survey, Pereira et al [1] studied the energy efficiency of 27 programming languages. These are the 10 most energy efficient programming languages according to their survey:
- C
- Rust
- C++
- Ada
- Java
- Pascal
- Chapel
- Lisp
- Ocaml
- Fortran
Out of the 27 programming languages that were surveyed, Python ranked 26. In one case, Python used 59x more energy than the most efficient language.
Now as a data scientist or ML engineer, it is difficult to avoid Python, and Python may in some cases be the best choice, for instance when building and training neural networks. However, there is potentially a lot of energy to be saved if you can build some of your surrounding applications or pipelines in a more energy efficient language.
You might not think it is surprising that Python is energy inefficient as it is infamously slow. However, the researchers interestingly found that speed does not always equate energy efficiency.
Here’s a short description of the methodology used in the paper:
The authors chose the 27 languages they found to be most common in programming (surprisingly, R didn’t make the list). For each of the 27 programming languages, the researchers measured the electricity required for completing 10 computing problems. For measuring the energy consumption, they used Intel’s Running Average Power Limit (RAPL) tool which allows you to obtain detailed estimates of energy consumption by the core, uncore and DRAM.
Read the scientific article for more details and the entire list of languages included in the survey.
Are you surprised? Would you switch programming language to save energy?
Follow me here on Medium and don’t hesitate to connect with me on LinkedIn if you share my interest in how we can make software engineering and data science greener.
[1] Pereira, R. et al. (2017) ‘Energy efficiency across programming languages: how do energy, time, and memory relate’. doi:10.1145/3136014.3136031.