How Environmental Friendly is Programming Languages

One thing that I have wondered about for a while is which programming language is the most environmentally friendly for the climate. Over my career, I have used many different programming languages, starting with Assembly as we build Operating Systems and working very closely with the hardware. Over the years, I got away from working closely with hardware, and now I primarily program in Python, PHP, Javascript and TypeScript.

I was not sure how I would get the information I was looking for to understand a programming language’s impact on the environment. Doing research, I found that a team of Portuguese university researchers attempted to quantify the energy efficiency of programming languages in a paper entitled Energy Efficiency across Programming Languages published in 2017. They looked at the runtime, memory usage, and energy consumption of twenty-seven well-known programming languages.

C is the most efficient programming language, while Python and Perl are the least environmental friendly programming languages.

The researcher’s focus was to understand the energy efficiency across various programming languages. This might seem like a simple task, but it is not as easy to define. They had to properly compare the energy efficiency between programming languages and various comparable implementations with a good
representation of different problems/solutions.

The researchers obtained a comparable, representative and extensive set of programs written in many of the most popular and widely used programming languages by using the Computer Language Benchmarks Game (CLBG) method.

The CLBG initiative includes a framework for running, testing and comparing implemented solutions for
a set of well-known, diverse programming problems.

From the 28 languages considered in the CLBG, the researchers excluded Smalltalk since the compiler for that language is proprietary. Also, for comparability, they discarded benchmark problems whose language coverage is below the threshold of 80%.

The outcome of the study shows that compiled languages tend to be the fastest and most energy-efficient ones. On average, compiled languages consumed 120J to execute the test solutions, while for the virtual machine and interpreted languages, this value was 576J and 2365J, respectively. This tendency can also be observed in execution time since compiled languages took

To understand this in more detail, we can take the binary-trees results to illustrate the point, starting with compiled code.

The graph concludes that “compiled languages tend to be the fastest and most energy-efficient ones.” C and C++ languages are the most efficient and fastest languages. Go is the worst language from the compiled languages category.

Next, we look at the binary trees in a VM that show us that Java or Erlang is the most efficient but far after compiled.

The inefficient languages go to interpreted languages like Perl, Lua, or Python, and that’s by some margin.

The study tests were performed on a machine based on an Intel Core i5-4460 Haswell CPU @ 3.20GHz with 16GB of RAM, and running Ubuntu Server 16.10 operating system with Linux 4.8.0-22.

The researcher ranked each language with different combinations of objectives mixing time, memory, and energy parameters, and C is coming out at the top. This study shows the efficiency of programming languages. If you are concerned about climate change, make your choice of programming language for your next project.

To sum it up

This was an eye-opening exercise for me. I have gone from using the more efficient languages like C and Assembly to some of the more environmentally inefficient programming languages like Python, PHP. It looks like I have been cutting corners going for programming languages that are easier to use. It also shows that the more efficient languages do not do that are used for the internet,

It would be interesting to do a study on what is the most efficient programming languages to build digital solutions for the web, mobile or desktop that is where we are to today. Making the right programming language choices when building new digital solutions for a sustainable further is important to us all.

Leave a reply:

Your email address will not be published.