The 10 most popular “green” programming languages

Computer programmers used to believe that a speedier programme would also be more energy efficient. The concept was applied to computer programming languages; according to the logic, a quicker language must be greener.

All of that changed in 2017, owing to a team of researchers from Portugal who developed the Computer Language Benchmarks Game (CLBG), a method for comparing the energy efficiency of various programming languages. The CLBG, developed in the early 2000s by programmer Doug Bagley, lays out a method for executing, testing, and evaluating software by resolving a collection of well-known, varied programming issues. The Portuguese researchers found that CLBG might be used to assess the energy efficiency of systems after it was originally developed to analyze runtime performance.

Computer industry professionals were captivated by their work. As a consequence of the positive feedback and interest in the original 2017 report, the researchers decided to revise the findings to account for languages that have gained in popularity since the original study’s completion and to represent the energy efficiency of those languages.

The CLBG covers 13 benchmark issues. They include actions like moving from one thread to another while passing a token, looking for answers to packing puzzles with symmetrical thread rendezvous requests, working with binary trees, and creating what is known as a Mandelbrot-set portable bitmap file.

27 languages’ energy use, execution times, and peak memory utilization were acquired by Portuguese researchers. The Running Average Power Limit (RAPL) tool, a feature of more modern Intel CPUs that provides the processor’s energy consumption, was employed by the researchers to measure the energy consumption. Each benchmark was run ten times to examine measurement consistency and to lessen the effect of cold starts and cache effects. Also true for memory usage.

As one would anticipate, compiled languages have typically proven to be the quickest and most energy efficient. Computed languages in the initial test used 120 J on average to run the test cases, whereas interpreted languages used 2,365 J. The same patterns showed up in terms of execution time: Compiling a language took 5,103 msec on average, but interpreting a language took 87,614 msec. 

 

rust, julia

 

Energy efficiency was also affected by programming paradigms. C and Fortran are examples of imperative languages, which need step-by-step instructions and take an average of 125 J and 5,585 msec. An average of 879 J and 32,965 ms were used by object-oriented languages like Java and C++, where objects include both data and code to manipulate the data. The benchmarks were run on functional languages like Python, which use 13,67 J on average and take 42,740 msec to complete. Python is designed to perform symbolic computing and list processing. Scripting languages like JavaScript, which interpret and carry out one instruction at a time using high-level constructs, typically used 2,320 J and took 88,322 milliseconds to complete.

The majority of the energy used, according to the experts, is always spent by the CPU. This amount, on average, accounts for 88.94% of the energy used by the compiled languages, with DRAM using the remaining energy. The consequence is that programme optimization to lower CPU-based energy consumption will also lower energy related to DRAM operations.

When compared to compiled (min. 85.27%, max. 91.75%) and virtual machine languages (min. 86.10%, max. 92.43%), the energy consumption numbers for interpreted languages (min. 81.57%, max. 92.90%) are more variable.

It is noteworthy to notice that the top four most energy efficient languages maintain their ranking when sorted by execution time and with very slight variances in both energy and time values, which raises the question of whether or not the quicker language is always the most energy efficient. Furthermore, it is well known that C, C++, and Rust are highly efficient and optimized for execution performance.

Researchers also offer their opinions on how memory use affects energy utilization. Continuous memory use and peak memory use are two different types of memory utilization. Researchers came to the conclusion that there does not appear to be a consistent relationship between peak memory use and DRAM energy consumption. 

 

Considering everything 

 

Language evaluations raise the question of whether there is a programming language that is “best” when taking into account peak memory utilization, execution time, and energy consumption, or if not, which programming languages are optimal in each specific situation. Researchers sorted the languages using the Pareto optimization multi-objective optimization algorithm in order to compare them using more than one characteristic at a time. The optimization goals were to maximize energy, time, and memory. In several instances, more than one programming language emerged as the Pareto optimal option. Additionally, the updated data from the previous year’s study were not used in the researchers’ Pareto optimization.

Researchers came to the conclusion that programmers who are just interested in execution time and energy usage may almost always select the appropriate language for the task. The choice of language is no longer automated, which is unfortunate if memory is also an issue. The most crucial characteristics in the current situation will need to be determined by developers.

According to the initial analysis, Rust was a close second to C in terms of overall energy efficiency. Rust and C are now tied for the top place as a result of the improved work. The new results show higher representation for more esoteric languages. Julia has primitives for parallel computing built-in and was created for numerical analysis. Both functional and object-oriented languages have components in OCaml. Functional programming languages like Lisp are built for working with data strings. Haskell is another functional programming language that is reputed to be particularly adept at managing concurrent systems with heavy loads, like web backends. The Chapel is a parallel software programming language created by Cray, a manufacturer of supercomputers. Google created the compiled language GO, which is similar to C in syntax but adds concurrency, garbage collection, and memory safety.