The Energy Efficiency of Programming Languages

 


What exactly is the energy consumption footprint of your chosen programming language? How would you go about producing an ESG summary of the workloads under your management? 

While this is a non-trivial ask, it is likely to be something we as engineers are asked to do, in much the same way as we have been asked to deliver on data and cyber governance. 

There are many variables at play here, ranging from fundamental language efficiency, developer competence and creativity in solutions architecture. But what exactly are those variables and would you be able to define them? Between 2017 and 2021 a team of researchers attempted to do exactly this and ranked a group of programming languages by their energy efficiency.


A fascinating couple of papers were published between 2017 and 2021 by a group of authors who attempted to measure the energy efficiency of a wide range of the most popular programming languages. 

The papers—which make essential reading if you are interested in software engineering, IT governance, energy utilisation, or ESG—are listed below in the References section.

I highly recommend checking them out, along with Trefethen and Thiyagalingam, which is an antecedent and discusses the challenges of establishing energy awareness in software.

And the Winner Is..

You could probably make an accurate guess at which programming languages came out top in the analysis and what characteristics made them so performant under test conditions (compiled vs. interpreted, etc.), so I won’t go into that. You could also guess where the shifting sands might lie underneath the results, but the authors address all of this in the analysis.

The real win from this work is the journey leading to the methodology the authors developed to conduct the analysis, and what that means for the rest of us who may soon need to perform similar analyses on our workloads.

Measuring Up

Several years elapsed between the authors’ first published version of the paper (Couto, M. et al., 2017) and the final peer-reviewed published version (Pereira, R. et al., 2021). It is interesting to see how the analysis deepened and extended during that time. Instead of sticking to a series of algorithmic benchmark comparisons, the analysis changed until the authors felt they adequately captured the energy consumption variables. Exploring the energy efficiency of software is a rabbit hole, and there are some indications in the papers of how deep and cavernous that rabbit hole can go.

One takeaway is that analysing energy consumption in software is hard. While there is tooling out there to help, it may not be enough or it may not suit your workload (Trefethen and Thiyagalingam, 2013). It will take time and iterations to find the right metrics and test methods that work for your organisation, so the sooner you start, the better.

Formulating best practices, frameworks, and patterns has been beneficial to the adoption of quality practices across software testing, gitops, and devops. Perhaps formulating similar resource consumption test patterns across programming languages, runtimes, and execution platforms could yield the kind of engagement that would deliver on ESG and save cost, time, and energy.

Why It Matters

Engineers will all be called upon to explain how our products and artefacts consume resources. The hyperscalers are already onto this - both from a language efficiency and memory safety perspective (see these from Google and Microsoft). For end-user organisations however, the angle of interest which is most likely to manifest itself is cost. To some degree, this is already upon those us in the guise of Cloud Economics, but the ESG dimension is really only starting for SE.

As we have seen from other governance-related paradigm shifts (data management, cybersecurity), there is a learning curve, and adoption won’t happen overnight. What is clear, however, is that organisations will need better support from hyperscalers and vendors to gauge the footprint of workloads as part of the development process.

Closing Thoughts

Read the papers. Read the papers. Read the papers.

Please Do. Both of them. It will provide a view of the evolution of the authors’ methodology and their explanation of the accrued value that evolution brought to the analysis.

As all strands of engineering are compelled to produce better accountancy for resource consumption, practitioners in the disciplines must demonstrate an understanding of how their engineered artefacts operate, and what variables exist within reach to callibrate this consumption.

References

Couto, M. et al. (2017) “Towards a Green Ranking for Programming Languages,” in Proceedings of the 21st Brazilian Symposium on programming languages. ACM, pp. 1–8. Available at: https://doi.org/10.1145/3125374.3125382. Permalink: https://library-search.open.ac.uk/permalink/44OPN_INST/j6vapu/cdi_acm_primary_3125382

Pereira, R. et al. (2021) “Ranking programming languages by energy efficiency,” Science of computer programming, 205, pp. 102609-. Available at: https://doi.org/10.1016/j.scico.2021.102609. Permalink: https://library-search.open.ac.uk/permalink/44OPN_INST/j6vapu/cdi_openaire_primary_doi_dedup_6ccb74e39bcd0033c3374cbd42444156

Trefethen, A.E. and Thiyagalingam, J. (2013) “Energy-aware software: Challenges, opportunities and strategies,” Journal of computational science, 4(6), pp. 444–449. Available at: https://doi.org/10.1016/j.jocs.2013.01.005. Permalink: https://library-search.open.ac.uk/permalink/44OPN_INST/j6vapu/cdi_webofscience_primary_000328184300003CitationCount