As a former software engineer who mainly worked with C programming, and to a lesser extent an assembler, I know in my heart that these are the two most efficient programming languages because they are so close to the hardware.
But to remove any doubt, a team of Portuguese university researchers attempted to quantify the energy efficiency of different programming languages (and their compiler / interpreter) in an article titled Energy efficiency through programming languages published in 2017, where they looked at the runtime, memory usage, and power consumption of twenty-seven well-known programming languages. It is the clear winner here being the most efficient, while Python, which I will now call the polluter programming language :), is at the bottom of the scale with Perl.
The study goes through the methodology and various benchmarks, but let’s choose the results of binary trees to illustrate the point starting with the compiled code.
To everyone’s surprise, the study concludes that “compiled languages tend to be, as expected, the fastest and most energy efficient.” C and C ++ languages are the most efficient and fastest languages. Go is the worst language in the category of compiled languages, and it’s even worse than virtual machine-based languages like Java or Erlang, at least with the sample binary trees used.
But the crown of the most inefficient languages goes to interpreted languages like Perl, Lua or Python, and that’s with a certain margin.
It should be noted that all tests were performed on a machine based on an Intel Core i5-4460 Haswell @ 3.20 GHz processor with 16 GB of RAM and running the operating system Ubuntu Server 16.10 with Linux 4.8.0- 22. Given that MicroPyhon now works on a wide range of microcontrollers, I suspect it might not be as bad on platforms with a smaller footprint, and it would be interesting to find out the difference.
The study also ranked each language with different combinations of goals mixing time, memory, and energy parameters, and C still leads with those metrics. This has been known for years, but if you want to optimize your program for battery life / low power consumption, some of the routines need to be optimized in C, assembler, SIMD instructions, or custom instructions for accelerators.
Going through Hackaday
Jean-Luc started CNX Software in 2010 part-time, before stepping down as head of software engineering and starting writing daily news and reviews full-time later in 2011.