Aspects to consider when comparing the energy-efficiency of programming languages

Yelle Lieder

Source: https://www.linkedin.com/posts/lieder_is-java-more-sustainable-than-typescript-activity-7090224312443363328-LYOJ

Development process 👩‍💻
The runtime behavior of software is only one aspect. The resource consumption in the development process as well as everything directly around the actual execution have to be considered additionally.

Comparability ⚖
Scientific benchmarks can only simulate real scenarios with difficulty. Measurement results from corresponding papers can therefore hardly be transferred meaningfully to productive systems.

Frameworks 🛠
The consideration of frameworks helps to classify numbers to the run time behavior of individual languages better, but also has its weaknesses.

Performance ≠ Sustainability ⛔
There is no linear relationship between code execution time and energy consumption. So twice as fast code is not directly twice as sustainable.

Life cycle ♻
Only a consideration of the entire life cycle of systems helps us to find out, which technologies are most sustainable for which use case. A one-dimensional consideration such as the comparison of runtime behavior should not be used as a basis for technology selection.

Mikey Hogarth

Source: YouTube comment under Ioannis Kolaxis – Fighting Climate Change by Building Sustainable Software (GOTO 2022)

Comment about efficiency of programming languages

The research he cites is based on the time it takes these languages to run a particular set of programming challenges. These challenges are not representative of the kinds of task you might undertake working on a software application. It also does not address the fact that things like Python, Ruby and so on are written in C or use c bindings for high-compute tasks. Take something like erlang - also written in C and also featuring quite low on the list in the research. By the time you've battered C or Rust into giving you the same features and benefits that erlang gives you, it'd probably feature quite low down on the list too because all the benefits require more compute.

The research even concludes this same point and states its purpose as being to make people aware, same as the speaker here does.

So yes - pick the most appropriate and energy efficient language - but please dont think this means all your Python devs now need to learn C. You might end up actually costing MORE carbon due to the hit your productivity takes.


As with most technical decisions, there are trade-offs to be made.

In this case, there's a trade-off between developer productivity (using a familiar language like Python along with its ecosystem of tools & libraries) and energy efficiency.

My recommendation in this presentation is: "Identify energy-consuming components, used by many users, and rewrite them in an energy-efficient language".
There is no need to rewrite your application from scratch; just identify the application components that consume the most energy (this may be identified by proxy metrics like CPU usage, etc.) and only consider rewriting these ones.
Likewise, if an application has a handful of users, you shouldn't bother rewriting it.