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 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.
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.
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, 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:
In contrast, interpreted languages such as Lua, Python, Perl, Ruby, and TypeScript were found to be the slowest and most energy-consuming.
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.
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.
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.
Address:
1855 S Ingram Mill Rd
STE# 201
Springfield, Mo 65804
Phone: 1-844-277-3386
Fax:417-429-2935
E-Mail: contact@appdevelopermagazine.com