Which Programming Languages Use the Least Power? Findings from a 2017 Study
A 2017 study by six Portuguese researchers compared the energy consumption, execution time, and memory usage of 27 programming languages across ten benchmark problems, revealing that faster languages aren't always more energy‑efficient and that compiled languages generally outperform interpreted ones in both speed and power usage.
When a phone’s battery is low, management software often prompts users to close high‑consumption apps, highlighting that software vendors, not just hardware manufacturers, must consider energy usage. This article examines a research study that compares the energy consumption of various programming languages.
The 2017 paper Energy Efficiency Across Programming Languages by six Portuguese researchers evaluated 27 languages by implementing solutions to ten benchmark problems from the Computer Language Benchmarks Game. They measured each language’s power consumption, execution time, and memory usage, producing a ranking illustrated below.
The study found that faster languages are not necessarily more energy‑efficient. For example, while C is generally the quickest and most power‑saving overall, Rust was the most energy‑efficient in a DNA‑sequence scanning benchmark, with C ranking third.
Results also varied depending on the metric used. In a test where Rust ranked first for energy, it fell nine positions when sorted by memory usage. Conversely, Fortran, second in energy efficiency, dropped six spots when ordered by execution time.
Methodologically, the researchers adhered to CLBG guidelines for compiler versions and optimization flags. Power was measured using Intel’s Running Average Power Limit tool, running each program ten times to mitigate cold‑start and cache effects. All tests were conducted on a desktop running Linux Ubuntu Server 16.10 (kernel 4.8.0‑22‑generic).
The common assumption that faster programs consume less energy was challenged; energy consumption does not scale linearly with time. An earlier study showed a Chapel program ran 55% faster than its Pascal equivalent yet used 10% more energy.
Overall, about 88% of the energy was consumed by the CPU, regardless of whether the language was compiled, interpreted, or run on a virtual machine. DRAM peak usage showed almost no correlation with total power draw.
In nine of the ten benchmarks, the top‑performing languages for both speed and energy were among C, C++, and Rust. Only four languages—OCaml, Haskell, Racket, and Python—maintained the same ranking for both criteria across all tests.
Compiled languages demonstrated a clear advantage: on average they required 120 J of energy, compared with 576 J for VM‑based languages and 2 365 J for interpreted languages. Execution times averaged 5 103 ms for compiled code, 20 623 ms for VM code, and 87 614 ms for interpreted code. The top four languages in both energy and speed rankings were compiled languages, with Java as the sole exception.
The five slowest languages were all interpreted: Lua, Python, Perl, Ruby, and TypeScript. The five most power‑hungry languages were also interpreted: Perl, Python, Ruby, JRuby, and Lua. However, for regex‑heavy tasks, three interpreted languages—TypeScript, JavaScript, and PHP—ranked among the most energy‑efficient.
Memory usage followed a similar pattern: compiled languages averaged 125 MB, VM languages 285 MB, and interpreted languages 426 MB. Four interpreted languages occupied the bottom of the memory ranking. By programming paradigm, imperative languages used the least memory (116 MB), followed by object‑oriented (249 MB), functional (251 MB), and scripting (421 MB). Imperative programs also tended to consume less energy and run faster than other paradigms.
Choosing a language depends on specific requirements. For workloads needing both low energy and fast execution, C is the optimal choice. If low memory and fast time are priorities, C, Pascal, and Go are suitable. When all three factors—time, energy, and memory—matter, the same conclusions apply, with C or Pascal being the best for low memory and energy.
In conclusion, software development is moving toward green programming and modernizing legacy systems to meet 21st‑century sustainability standards.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
