Sunday, November 27

Electricity is so expensive that finding out which is the most efficient programming language is a good idea


With the price of electricity through the roof, trying to be more efficient is a shared goal in all kinds of areas. We are looking for plans B of all kinds to minimize dependencies and extra consumption. And an area in which it is also possible to set this objective is software development. How to program more efficiently?

What programming language spends less electricity? A study carried out by Portuguese researchers already tried to answer this question in 2017. In their analysis —the code used is available on GitHub— they considered both the use of memory and the energy consumed in the execution of a special set of programs.

Measuring consumption. This set of programs is called Computer Language Benchmarks Game and it is a Free Software project that allows you to compare how certain algorithms are implemented in different programming languages. In this process, the execution time, memory consumption or CPU usage are analyzed.

27 opposing languages. In the analysis, different programming languages ​​belonging to different paradigms were compared: functional, imperative, object-oriented and scripting. Here there were from classic languages ​​such as C or C++ to more modern alternatives such as Rust and also well-known ones such as Javascript, Perl, PHP or Python.

Screenshot 2022 09 21 At 11 43 16

Source: University of Minho.

C, Rust and C++ win separately. When studying power consumption, execution time and memory consumed, the normalized data shows C, Rust and C++ as winners. Among the worst behaved were Python, Perl, Ruby, Lua or PHP. There are also curiosities: very old languages ​​such as Pascal or Fortran do not consume much, but their low memory usage is striking, probably because they were designed when that resource was especially limited. In general compiled languages ​​seem to be more efficient than interpreted ones.

Also Read  Someone has created Lexica, a search engine for images generated by Stable Diffusion: this is how you can take advantage of it

Screenshot 2022 09 21 At 11 49 22

let’s make couples. Although that was the general classification, the researchers also wanted to give options to those seeking to solve combined efficiency problems. Thus, they indicated the best languages ​​to save execution time and memory (C, Pascal and Go win), energy and time (C, Rust and C++), energy and memory (C and Pascal) or the three objectives, energy, time and memory (C, Pascal and Go stand out).

An imperfect study. The study has already sparked debate on social media. like twitter, and in comments on Hacker News several developers indicated that the code was not ideal for comparison. Thus, a user explained that this code “does not reflect how languages ​​like Python behave in practice”, but in reality the question is not that.

The great paradox of the gas cap: why we have come out ahead despite having to pay more than ever

Efficiency is not the priority. As another user explained, if you want to be really efficient, the ideal would be to program in assembler. Although it may be interesting to know which language is more efficient, it is even more important to be clear that certain programming languages ​​are perfect for some things, while others are for others. In fact, in this area, what is clear is that the most popular programming languages ​​are not the most popular —Rust is the most fashionable, for example— nor are they the ones that make the most money.

Image | james harrison



Leave a Reply

Your email address will not be published. Required fields are marked *