Programming in C saves the environment



Listen, I love Javascript as much as the next guy. Yes, it’s a mess but it also pays the bill. Unfortunately, our planet is dying and its because people like you and me who are too stubborn and insist on using Javascript for everything. App Development, Web Development, Server development, etc.

So how can you be a good citizen and save the planet? The answer lies in a research paper published from Portugal. In the paper, they examine the energy efficiency of twenty-five different programming languages and try to determine the most energy efficient language. They use the Computer Language Benchmarks Game to develop a consistent testing environment for each of the languages. For each trial, they measure the energy output (in joules) from the CPU and DRAM, execution time and memory usage.

Most Energy Efficient Language

Just as a quick refresh, recall the areas that each programming language belongs to:

languages

After performing a couple of trials, the researchers were able to rank the languages in terms of energy efficiency

:

 

It should come as no surprise that their findings revealed that compiled languages had faster execution time and a lower memory footprint than interpreted languages. Remember, interpreted languages have no compile stage. The conversion to byte-code happens at runtime for the language.

Power Output

Most people would agree that total energy is the product of time and power. Assuming power is constant, decreasing execution time would lead to a decrease the total energy used by the program. The researchers found that this was not always the case. For example, Fortran used less energy than C in a particular benchmark but its execution time was a whole lot longer.

This anomaly reveals that power isn’t a constant value. Perhaps the way a compiler is implemented could give it a power advantage with certain system calls.

Wait, don’t drop Javascript

Before you switch careers to a Systems developer, know that there is still a place for interpreted languages like Javascript. The researchers found that in benchmarks involving strings and regular expressions, interpreted languages were much more energy efficient than compiled languages.

Hopefully it’s apparent that there are many benefits to programming in C. Also, the energy efficiency of each programming language can vary greatly depending on the task. At the end of the day, I’m going to look for other ways to save the environment that will not involve me leaving my beloved JavaScript.