Hey Guys,
It’s been a while since I’ve seen this topic covered. As a fan of both ESG and Green Technology and programming languages I was curious. So I looked it up.
Tl;dr here are the results:
I somewhat suspected C and Rust would be near the top here. This is based on a 2021, the original study was in 2017.
Top Green Programming Languages
C
Rust
Java
Swift
Haskell
C#
Go
Dart
JavaScript
TypeScript
“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.”
This study implemented 10 benchmark problems in 27 different programming languages and measure execution time, energy consumption, and peak memory use.
𝗖 𝗶𝘀 𝘁𝗵𝗲 𝗺𝗼𝘀𝘁 𝗲𝗳𝗳𝗶𝗰𝗶𝗲𝗻𝘁 𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗹𝗮𝗻𝗴𝘂𝗮𝗴𝗲, 𝘄𝗵𝗶𝗹𝗲 𝗣𝘆𝘁𝗵𝗼𝗻 𝗮𝗻𝗱 𝗣𝗲𝗿𝗹 𝗮𝗿𝗲 𝘁𝗵𝗲 𝗹𝗲𝗮𝘀𝘁 𝗲𝗻𝘃𝗶𝗿𝗼𝗻𝗺𝗲𝗻𝘁𝗮𝗹 𝗳𝗿𝗶𝗲𝗻𝗱𝗹𝘆 𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗹𝗮𝗻𝗴𝘂𝗮𝗴𝗲𝘀.
Full text: https://medium.com/codex/what-are-the-greenest-programming-languages-e738774b1957.
The original report with updated info: https://sites.google.com/view/energy-efficiency-languages/.
Post credit: I saw it on Dr. Milan Milanović’s account.
🌐 A very common misconception when analyzing energy consumption in software is that it will behave in the same way execution time does. In other words, reducing the execution time of a program would bring about the same amount of energy reduction. However power doesn’t follow this rule.
The Computer Language Benchmarks Game
The CLBG initiative includes a framework for running, testing and comparing implemented coherent solutions for a set of well-known, diverse programming problems.
You can see the complete results here.
I think in some ways the paper is very theoretical and novel and may not fully be totally representative of the challenge of the question, but is pretty amusing at least. I wonder a few years later if this would have changed using the same methodology. As new languages are rolled out like Carbon I wonder if they take this into consideration:
In Case you Missed It
The study is now about five years old:
The paper was popularized by the Rust people from AWS, and many software engineers don’t take it entirely seriously. However it’s highly shareable and stirs up some useful debate.
You can read a 2021 update to this question here.
There are many variables the study did not take into account according to commentators:
Skill of the engineers themselves.
Debugging energy
Lifecycle energy cost
Impact of JIT compilers of many languages
Still the article is a rare example of asking an important and tough question and trying to find the most relevant benchmarks.
Join 33 other paying subscribers for additional content and locked archive posts.