Energy Consumption of a Programming Language

Published on Sep 14, 2020

Today I read a paper benchmarking different programming languages according to the amount of energy they consume, and it blew me away:  

  • Javascript consumes 4.5 times more energy than C 
  • PHP consumes 5 times more than Javascript 
  • Ruby and Python consume more than twice what PHP does  

Interpreted languages, which are so common in web development, are often far more energy intensive than their compiled counterparts. Java is the exception with only twice C's consumption.

This is particularly interesting for me since I'm trying to be more mindful about my tech choices in regard to the environment (with green hosting and offline-first web development). If my website can consume five times less energy by switching from PHP to Javascript, it's indeed very important to take that into account. If I can skip interpreted languages and rely on the .htaccess configuration of my Apache instance (written in C) to serve static web pages, it's even better.

I'm kind of surprised this is the first time someone thought about making this study, 2017 being relatively recent. I stumbled upon it by sheer luck, and no one ever mentions this performance indicator when talking about differences between programming languages.

Worse, I'm trusting web carbon footprint calculators less and less since they don't take into account this basic thing. There is probably an open source project to make around this paper to help the tech industry moves toward a greener future.