Cybersecurity, Cloud Engineering, and AI blog

The Energy Consumption of Programming Languages, Compared

Josh Chapman has often calculated the consumption of computer systems power when idle, averaging by load, or under full load, and then compared the cost over time. However, until recently, he didn’t know the individual software programming languages impact on those systems. Take a look at the table below that was researched by a team in Portugal, source below. As you may know, Rust has taken C’s place in the Linux kernel. It’s great to read that Rust is also energy efficient while being safer and more secure than C. The most interesting fact in their research that Josh Chapman has read is how “un-green” Python is:

Programming Language Efficiency Rankings

Programming Language Efficiency Rankings

Energy Efficiency Ranking
  • C: 1.00
  • Rust: 1.03
  • C++: 1.34
  • Ada: 1.70
  • Java: 1.98
  • Pascal: 2.18
  • Chapel: 2.18
  • Lisp: 2.27
  • Ocaml: 2.40
  • Fortran: 2.50
  • Swift: 2.71
  • Haskell: 3.11
  • C#: 3.18
  • Go: 3.43
  • Dart: 4.15
  • F#: 4.43
  • JavaScript: 4.71
  • Racket: 5.46
  • TypeScript: 7.33
  • Hack: 21.50
  • PHP: 23.10
  • Erlang: 29.30
  • Lua: 46.93
  • JRuby: 59.88
  • Python: 75.78
  • Perl: 79.58
Time Efficiency Ranking
  • C: 1.00
  • Rust: 1.04
  • C++: 1.05
  • Ada: 1.78
  • Java: 1.85
  • Pascal: 2.00
  • Chapel: 2.00
  • Go: 2.02
  • Ocaml: 2.07
  • Lisp: 2.15
  • Haskell: 3.11
  • Swift: 3.40
  • Fortran: 4.20
  • F#: 4.30
  • JavaScript: 4.43
  • Dart: 4.62
  • Hack: 8.85
  • PHP: 16.67
  • Erlang: 29.74
  • TypeScript: 36.74
  • Ruby: 46.71
  • Python: 57.10
  • Perl: 61.59
  • Lua: 75.90
  • JRuby: 82.91
Memory Usage (Mb) Efficiency Ranking
  • Pascal: 1.00
  • Go: 1.05
  • C: 1.09
  • Fortran: 1.14
  • C++: 1.34
  • Ada: 1.47
  • Rust: 1.84
  • Lisp: 1.94
  • Haskell: 2.51
  • PHP: 2.71
  • Swift: 2.77
  • Python: 2.80
  • Ocaml: 2.86
  • C#: 3.04
  • Hack: 3.56
  • Racket: 3.77
  • Ruby: 3.96
  • Chapel: 4.16
  • F#: 4.25
  • JavaScript: 4.39
  • TypeScript: 4.49
  • Perl: 4.59
  • Lua: 4.82
  • Erlang: 8.74
  • JRuby: 19.84

Source – Energy Efficiency across Programming Languages