avatarKesk -*-

Summary

Researchers have evaluated the energy efficiency of 27 programming languages, revealing that C, C++, Rust, and Java rank among the "greenest" due to lower energy consumption, despite Java's higher memory usage.

Abstract

A study conducted by Portuguese researchers and presented at the International Conference on Software Language Engineering 2017, with updated results in 2021, assessed the runtime, memory usage, and energy consumption of 27 popular programming languages. The study employed ten diverse programming problems from the Computer Language Benchmarks Game and used Intel's RAPL tool for precise power consumption measurements. The findings indicate that while execution speed influences energy consumption, it is not the sole factor; memory usage also plays a significant role. The results show that C, C++, and Rust are among the most energy-efficient languages, with Java also performing well in energy consumption but not in memory efficiency. Interpreted languages like JavaScript and Python tend to consume more energy and take longer to execute, making them less environmentally friendly. The study suggests that these insights can guide software engineers in selecting energy-efficient programming languages, which is increasingly important in a world where energy consumption and environmental impact are growing concerns.

Opinions

  • The choice of programming language can have a significant impact on energy efficiency, which should be considered alongside traditional factors like syntax and community support.
  • Faster execution does not always equate to lower energy consumption; memory usage is also a crucial determinant.
  • C, C++, and Rust are commended for their energy efficiency, making them suitable choices for environmentally conscious developers.
  • Java's energy efficiency is notable, but its high memory usage should be taken into account.
  • Interpreted languages like JavaScript and Python, while popular, are identified as less energy-efficient options, which may influence their use in resource-intensive applications.
  • The research provides a new parameter for developers to consider, emphasizing the importance of energy efficiency in software development.
  • The study's findings could contribute to the design of more efficient programming languages and influence the future of software engineering with environmental considerations in mind.

What Are the Greenest Programming Languages?

Programming languages and energy consumption

Photo by Alena Koval from Pexels

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.

Energy ranking,

Time

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

Execution time ranking.

Memory

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

Memory ranking.

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

Paper

https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game

Programming
Programming Languages
Green Energy
Software Development
Software
Recommended from ReadMedium