C Is The Greenest Programming Language

Have you ever wondered if there is a correlation between a computer’s energy consumption and the choice of programming languages? Well, a group of Portuguese university researchers did and set out to quantify it. Their 2017 research paper entitled Energy Efficiency across Programming Languages / How Do Energy, Time, and Memory Relate?  may have escaped your attention, as it did ours.

Abstract: This paper presents a study of the runtime, memory usage and energy consumption of twenty seven well-known soft- ware languages. We monitor the performance of such lan- guages using ten different programming problems, expressed in each of the languages. Our results show interesting find- ings, such as, slower/faster languages consuming less/more energy, and how memory usage influences energy consump- tion. We show how to use our results to provide software engineers support to decide which language to use when energy efficiency is a concern.

While we might take issue with some of the programming languages selected as being “well known”, the project was very thorough and quite well documented. Most people would take for granted that a computer program which runs faster will consume less energy. But this might not always be true, as other factors enter into the power consumption equation besides speed. The team used a collection of ten standard algorithms from the Computer Language Benchmarks Game project (formerly known as The Great Computer Language Shootout) as the basis for their evaluations.

Last year they updated the functional language results, and all the setups, benchmarks, and collected data can be found here. Check out the paper for more details. Have your choice of programming language ever been influenced by energy consumption?

184 thoughts on “C Is The Greenest Programming Language

  1. I created GO versions of our background server processes and reduced CPU and memory usage by a lot. I didn’t measure the CPU but did notice that the overall CPU usage dropped. Memory usage was reduced by 90% over Java. YMMV.

  2. Intresting, but how about assembler, which I use for the simple fact that you cannot beat it for effieciency?

    It would be good to see this included as we have apps running that have accumulated decades of service on a singe cell battery, never crashed, something that would be challange using a higer level language.

      1. Yup on your observation that many assembler/machine binaries have been working for decades without crashing aapears correct?

        2023.

        Can gcc c compiler-produced transparent portable machine binaries match equal in efficiency of hand-coded assembler machine binaries for x86, arm m and a and risc-v platforms?

        1. IBM 360 FORTAN compiler writers got so good in ~1975 that their machine code could not be surpassed in efficiency by human assembler code.

          How does gcc c transparent portable x86, arm m and a series, risc-v do in 2023?

Leave a Reply to atbillp37Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.