Programming
How 27 programming languages differ in energy consumption
Monday, July 14, 2025
|
Russ Scritchfield |
A new study reported by The New Stack analyzes how 27 programming languages differ in energy consumption, speed, and memory use, revealing compiled languages like C and Rust as the most efficient, though no single language dominates all scenarios.
A research team from Portugal has conducted a comprehensive study analyzing how different programming languages impact energy consumption, execution time, and memory usage. Their findings were published in the paper Energy Efficiency Across Programming Languages, as reported by technology news outlet The New Stack.
The Most Energy-Efficient Programming Languages Revealed: How 27 programming languages differ in energy consumption
The study evaluated 27 programming languages by running solutions to 10 standard algorithmic problems sourced from the Computer Language Benchmarks Game (CLBG), a free software project designed to compare performance across languages. This allowed researchers to assess the energy usage, speed, and memory footprint of each language under consistent conditions.
The tests were executed on a Linux Ubuntu Server 16.10 system with a Haswell Intel Core i5-4460 CPU and 16GB of RAM. Power consumption was measured using Intel's Running Average Power Limit tool, with each program run 10 times to ensure consistent and reliable results.
C and Rust Among the Most Energy Efficient
The results confirmed that the C language remains both the fastest and the most energy-efficient overall. However, performance varied depending on the specific task. For example, when scanning a DNA database for a genetic sequence, Rust outperformed other languages in energy efficiency, while C ranked third for energy usage and second for speed.
Fortran also demonstrated strong energy efficiency in certain tests, though its execution time was slower compared to other top performers.
Speed Does Not Always Equal Lower Energy Use
The researchers challenged the assumption that faster programs inherently consume less energy. Their data showed that execution speed and energy consumption do not always correlate. In one benchmark, a program written in Chapel executed 55 percent faster than its Pascal equivalent, yet the Pascal program used 10 percent less energy.
The study further revealed that, on average, the CPU accounted for 88 percent of power consumption, regardless of whether programs were compiled, interpreted, or run on a virtual machine. Interpreted languages showed more variability in CPU energy use, ranging from 81.57 percent to 92.90 percent.
Compiled Languages Outperform in Energy and Speed
Compiled languages, including C, Rust, C++, and Ada, dominated both energy efficiency and execution speed metrics. On average, compiled languages consumed just 120 joules (J) to execute solutions, compared to 576J for virtual machine languages and 2365J for interpreted languages.
The top five most energy-efficient and fastest languages included:
- C (57J, 2019ms)
- Rust (59J, 2103ms)
- C++ (77J, 3155ms)
- Ada (98J, 3740ms)
- Java (114J, 3821ms)
In contrast, interpreted languages such as Lua, Python, Perl, Ruby, and TypeScript were found to be the slowest and most energy-consuming.
Memory Usage Reflects Similar Trends
Compiled languages also proved to be more memory-efficient. Pascal, Go, C, Fortran, and C++ required the least memory, with Pascal using just 66 megabytes (MB). Interpreted languages, including JRuby, Dart, Lua, and Perl, occupied the bottom rankings for memory usage, with some requiring over 400MB.
When analyzed by programming paradigm, imperative languages were the most efficient in both energy consumption and execution time. Programs written in imperative languages used an average of 125J and executed in 5585 milliseconds, significantly outperforming object-oriented, functional, and scripting paradigms.
No Universal Best Language
Despite these findings, the researchers emphasized that no single language consistently outperforms others across all scenarios. Factors such as compiler quality, libraries used, and specific application requirements all influence energy consumption and performance.
In scenarios where both energy use and execution time are critical, C emerged as the best overall option. When considering energy and memory usage together, C and Pascal were the top choices. For developers optimizing across all three metrics—energy, time, and memory—C, Pascal, and Go were identified as strong candidates.
Further Research and Practical Applications
The study's data has been made publicly available to support further research into energy-efficient programming. The findings have particular relevance for developers working on mobile apps, IoT devices, and other applications where power consumption is a major constraint.
The research offers valuable insights but also underscores the complexity of the topic. As the authors conclude, “The situation on which a language is going to be used is a core aspect to determine if that language is the most energy-efficient option.”
Full coverage of the study was provided by David Cassel for The New Stack. Cassel has covered technology news for over two decades, contributing to outlets such as CNN, MSNBC, and the Wall Street Journal Interactive.
How 27 programming languages differ in energy consumption
Normalized global results for energy time and memory
Become a subscriber of App Developer Magazine for just $5.99 a month and take advantage of all these perks.
MEMBERS GET ACCESS TO
- - Exclusive content from leaders in the industry
- - Q&A articles from industry leaders
- - Tips and tricks from the most successful developers weekly
- - Monthly issues, including all 90+ back-issues since 2012
- - Event discounts and early-bird signups
- - Gain insight from top achievers in the app store
- - Learn what tools to use, what SDK's to use, and more
Subscribe here
