Here’s How Much Electricity Your Favourite Programming Language Consumes

Software energy consumption is becoming a major problem for computer makers, software language engineers, programmers, and even ordinary computer users.

Can you decide which programming language to use when energy efficiency is a concern? Unfortunately, no. To make things easier, a team of six researchers from three different universities in Portugal decided to investigate the performance of programming languages. 

In a research paper titled “Energy Efficiency across Programming Languages,” the team presented a study of the runtime, energy consumption, and memory usage of twenty-seven well-known software languages.

Over the past several years, one can sense that the strategies were created with the intention of assisting software engineers in creating faster programmes. Indeed, performance in software languages was nearly always associated with fast execution times (embedded systems were probably the single exception). However, this reality is rapidly changing in the twenty-first century, and software energy consumption is becoming a major problem for computer makers, software language engineers, programmers, and even ordinary computer users. The results for energy, time and memory are shown below.

AIM Daily XO

Join our editors every weekday evening as they steer you through the most significant news of the day, introduce you to fresh perspectives, and provide unexpected moments of joy
Your newsletter subscriptions are subject to AIM Privacy Policy and Terms and Conditions.

Image: Research paper

Researchers used the Computer Language Benchmarks Game (CLBG) to compare and analyse the energy efficiency of different software programming languages. They used ten problems from the CLBG – a free software project that contains a standard collection of simple algorithmic tasks as well as a framework for executing tests for comparing performance. 

Download our Mobile App

Further, to measure energy consumption, the team used Intel’s Running Average Power Limit (RAPL) tool, capable of providing accurate energy estimates at a very fine-grained level with a proven history, as researchers informed. Also, the current version of RAPL allows it to be invoked from any program written in C and Java.

Is faster greener?

As per the paper, an interesting question that frequently arises in the software energy efficiency area is whether a faster program is also an energy-efficient program. The researchers point out that it isn’t as straightforward as the physics formula E (energy) = T (time) x P (power). This is partly due to the fact that power is not consumed at a steady rate, according to the researchers, who speculate that this may be influencing the work of other academics looking into how a program’s running time is related to its energy consumption. While it’s still widely assumed that faster programmes use less energy, the researchers come to a conclusion that a faster language is not always the most energy-efficient.

However, the question is hard to answer as many factors creep while measuring power consumption. This includes the quality of the compiler, libraries used, etc. However, the researchers were able to separate energy use by CPU or DRAM utilisation, determining that the CPU consumed the majority of power, about 88.94% on average, and the remaining portion was assigned to DRAM (or dynamic RAM) — regardless of whether the benchmark programme was compiled, interpreted, or executed on a virtual machine.

Additionally, while trying to figure out the possibility of a correlation between the DRAM’s energy consumption and peak memory usage, the group was surprised to note that the relationship is almost non-existent. As a result, it’s evident that DRAM energy usage has less to do with how much memory is saved at any given time and possibly more to do with how it is used.

Further to this, to compare the languages using three characteristics – energy consumption, execution time, and peak memory usage – at a time, they used a multi-objective optimisation algorithm to sort these languages, known as Pareto optimisation. 

Wrapping up

The work presented in this paper by the Portuguese researchers extends the work presented in the paper titled ”Towards a Green Ranking for Programming Languages”, where the energy consumption monitoring approach for different programming languages was introduced. In this paper, the researchers have described a study on the energy efficiency of ten different programming languages, considering a corpus of ten computing problems included in the CLBG project. They monitored the energy consumed and execution time of almost a hundred computer programs. The study concludes that C is the fastest and greenest language. However, the results also show that energy consumption is not always directly proportional to execution time. In fact, there are greener programming languages while being slower than others. 

Sign up for The Deep Learning Podcast

by Vijayalakshmi Anandan

The Deep Learning Curve is a technology-based podcast hosted by Vijayalakshmi Anandan - Video Presenter and Podcaster at Analytics India Magazine. This podcast is the narrator's journey of curiosity and discovery in the world of technology.

kumar Gandharv
Kumar Gandharv, PGD in English Journalism (IIMC, Delhi), is setting out on a journey as a tech Journalist at AIM. A keen observer of National and IR-related news.

Our Upcoming Events

27-28th Apr, 2023 I Bangalore
Data Engineering Summit (DES) 2023

23 Jun, 2023 | Bangalore
MachineCon India 2023

21 Jul, 2023 | New York
MachineCon USA 2023

3 Ways to Join our Community

Telegram group

Discover special offers, top stories, upcoming events, and more.

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Subscribe to our Daily newsletter

Get our daily awesome stories & videos in your inbox

The Great Indian IT Reshuffling

While both the top guns of TCS and Tech Mahindra are reflecting rather positive signs to the media, the reason behind the resignations is far more grave.

OpenAI, a Data Scavenging Company for Microsoft

While it might be true that the investment was for furthering AI research, this partnership is also providing Microsoft with one of the greatest assets of this digital age, data​​, and—perhaps to make it worse—that data might be yours.