Save the planet! Program in C, avoid Python, Perl

As a former software engineer who’s mostly worked with C programming, and to a lesser extent assembler, I know in my heart that those are the two most efficient programming languages since they are so close to the hardware.

But to remove any doubts, a team of Portuguese university researchers attempted to quantify the energy efficiency of different programming languages (and of their compiler/interpreter) in a paper entitled Energy Efficiency across Programming Languages published in 2017, where they looked at the runtime, memory usage, and energy consumption of twenty-seven well-known programming languages. C is the uncontested winner here being the most efficient, while Python, which I’ll now call the polluters’ programming language :), is right at the bottom of the scale together with Perl.

The study goes through the methodology and various benchmarks, but let’s pick the binary-trees results to illustrate the point starting with compiled code.

binary-trees compiledTo the surprise of no one, the study concludes that “compiled languages tend to be, as expected, the fastest and most energy-efficient ones”.C and C++ languages are the most efficient and fastest languages. Go is the worst language from the compiled languages category, and it’s even worse than languages relying on a VM like Java or Erlang, at least with the binary-trees sample used.

code efficiency VM

But the crown of the most inefficient languages goes to interpreted languages like Perl, Lua, or Python, and that’s by some margin.

interpreted languages poor efficiencyIt should be noted all tests were performed on a machine based on an Intel Core i5-4460 Haswell CPU @ 3.20GHz with 16GB of RAM, and running Ubuntu Server 16.10 operating system with Linux 4.8.0-22. Considering MicroPyhon is now running on a wide range of microcontrollers, I suspect it may not be as bad on those platforms with a smaller footprint, and it would be interesting to find out the difference.

time memory energy programming languagesThe study also ranked each language with different combinations of objectives mixing time, memory, and energy parameters, and C is always at the top with those metrics. That’s been known for years, but if you want to optimize your program for battery life/low power, some of the routines would have to be optimized in C, assembler, SIMD instructions, or custom instructions for accelerators.

Via Hackaday

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
105 Comments
oldest
newest
nick
nick
2 years ago

C is probably the most dangerous language – did the researchers factor in the amount of downtime and damage caused by badly written C that crashes.

dgp
dgp
2 years ago

I’m not going to claim that C is perfect or anything but whatever language you use it runs on the same machine. If the machine allows for badness it will eventually happen whether you use so called safe languages or not. I think a lot of new languages introduce issues of their own. You might be avoiding stupid memory errors (which we have lots of tooling to find and debug now even for C) but now you’re adding a ton of untrustable code from the built in package manager. Why bother searching high and low for a memory error you… Read more »

Frank Earl
Frank Earl
2 years ago

Bingo!

Scott Lamb
2 years ago

Do new languages add “a ton of untrustable code from the built in package manager”? Eh, maybe. Yes, many programs use lots of dependencies from random people with essentially no review, so malicious code is worth considering. But there are ways to address it. You don’t have to use external packages at all. More realistically, you can use packages sparingly only from trusted/vetted authors. You can (and should) check in lockfiles (which include dependency version numbers and content hashes) so that new, potentially malicious versions aren’t picked up by accident. You can vendor dependencies. There are young but promising tools… Read more »

Noloqoq
Noloqoq
2 years ago

Well that’s exactly what Linux distribution packaging systems do. They manages dependencies, and you can so see, which libs are used, mainly in C, sometime in other languages with C made libs having binding in other languages. Happily Python, also use CCI to reduce Python scripting waste and use more compiled code, in cpu/other processors intensive part.

bkydcmpr
bkydcmpr
2 years ago

You don’t have to use external packages at all”, you must be doing your CS 101 homework. No, it’s inevitable in the industry.

Frank Earl
Frank Earl
2 years ago

Badly written code shouldn’t count into things. Trying to protect people from themselves is where a good part of those inefficiencies come from. There’s something called, “skill,” that needs to be accounted for. SERIOUSLY. I don’t want something with a safety net because it leads to devs being sloppy.

2 years ago

Your paper is 4, almost 5 years old. Although Python has made good strides in speed with some branches near C speeds, it’s a moot point with CPU power steadily increasing. But it’s big advantage over C is almost everyone can pick it and use it. It is more maintainable and as a runtime errors in code can be quickly located and squashed. But bad code is still bad code and will still be present. The other advantage is speed of development vs C. Adding a new feature takes 3 or more times that of Python. So over time the… Read more »

Sheldon
Sheldon
2 years ago

You can write bad code in ever language. Getting a crash because of an uncatched exception is not better. Catching it and don’t reacting on it correctly is even worse, because you are hiding the real error source. C programmers know to check malloc result and handle OOM. I don’t know any high level Java or C# programs that can deal with OOM. The devs silently assume mem is an infinite resource. Also critical software in satilites, airplanes etc. is still written in C, because it is deterministic and and can be proven to be correct. Every lamguage with a… Read more »

Occam
Occam
2 years ago

It’s been a long time since compsci but I think it’s been proven that’s it’s impossible to prove any arbitrary complex program to be correct.

Willy
2 years ago

When looking for statistics on this in WAF products, you’ll notice that C is almost not represented in remotely exploitable bugs, contrary to all the horrors you can do in languages supporting evaluation or exec, such as PHP, which is by far the most feared in hosting environments.

Scott Lamb
2 years ago

WAF as in Web Application Firewall? Not surprised to hear C is almost not represented in WAF statistics; almost no web applications are written in C. Code that doesn’t exist is secure but maybe not so functional… For things that are written in C/C++, about 70% of security errors are due to memory safety problems. (Strikingly, Microsoft and Chromium gave this same percentage for their respective security bugs.) Memory-safe languages are effective at eliminating most of these errors. I particularly like Rust. In safe Rust (and I use “unsafe” in <1% of the Rust lines I write), I have memory… Read more »

willy
willy
2 years ago

It’s fun to read that it doesn’t exist or is not secure, because virtually *all* the products that are put at the edge and that are there to serve the ones that need a WAF are actually written in C. NGINX, Apache, Varnish, HAProxy, Lighttpd, Litespeed. Thus they are the first ones taking all the attacks and the least represented in the vuln database. And one can wonder what it would be like if they were not at the front to deal with the horrors they’re dealing with, protecting the next level…

Scott Lamb
2 years ago

Out of interest, what vulnerability database are you looking at? You might be right that they’re least represented, but they’re not immune. I remember some high-profile vulnerabilities in Apache, for example. There’s been a tremendous effort put into each line of those six http servers. They’re standard, well-respected, open-source software, some of them developed over decades, and that’s nearly a complete list of the ones folks use. They’re completely dwarfed in line count by web application code, which again just isn’t written in C. I couldn’t list just six web apps that are all most sites use. In fact, most… Read more »

Willy
2 years ago

I’m aware of at least one banking application written in C and it’s not that buggy. However it has always cost a lot in upgrades. I mean, there’s virtually no maintenance. It works, there are no moving parts, period. But when a new feature is requested, it costs more to add than in newer languages. And developers are 3 times as expensive as those you need for Java or others found in such environments.

Diogene
Diogene
2 years ago

In that case the issue is the programmer not the language. Even bad written code vs good one can have a big impact on performance and efficiency.
When you see self defined high level software engineer dividing a integer by a 2^n instead of bit shift you understand that the issue is not the language.

willy
willy
2 years ago

Absolutely! The sad thing is that bad developers tend to restrict what they can use to what Google or StackOverflow can propose them as a starter.

^Oo^
^Oo^
2 years ago

What a load of shite.

Marco
Marco
2 years ago

I program in c++ and the universe is written in C. It does not matter if you have a Lamborghini if you don’t know how to drive. 🙂

Phyo Arkar Lwin
Phyo Arkar Lwin
2 years ago

Stop spreading bullshit, unoptimized C is many times resources intensive, error prone,less secure. You could die before making a C program behave well , smooth, green and fast.
There are a lot better Candidate like nim-lang which is close to C in performance and as easy as python.

Willy
2 years ago

Fortunately over the last 50 years there were thousands of people who had way less difficulty than you imagine and could build the whole internet that you can use today to post such uneducated messages 🙂

Mee
Mee
2 years ago

Seems like Rust should be the “go to” language if you want speed, efficiency and safety.

Frank Earl
Frank Earl
2 years ago

No, because it’s got complex constructs that are hard to follow, etc. The problem with Rust is that it’s trying to do the same things that the latest C++ standards are doing coupled with what Haskell does well (The efficiency in Rust comes at other prices)- with i’s own new syntax and ROE that do not give you the same things.

Noloqoq
Noloqoq
2 years ago

I for now never seen piece of software in Rust that was as fast as C version. And they consume generally lot of HDD, due to the wrong habit to statically link all the libs, with security issues+compilation waste that come with it when update is needed.

Glynne
Glynne
2 years ago

I agree, we should demand speed, efficiency and safety… but you misspelled Ada

willy
willy
2 years ago

That’s what some say, but finding developers who are able to decipher that smiley-based language is not easy yet.

Sander
Sander
2 years ago

The low-energry consumption of C/C++ became only relevant when programs moved from client side to provider/cloud … because only then the provider had to pay himself for the energy consumed. That caused a raise in popularity in C/C++ in the past 1-2 past decade.

Frank Earl
Frank Earl
2 years ago

It actually came into play much earlier on. The notion that C/C++ wasn’t popular prior to this and all is a silly notion out of box. You just came late to the party. That’s what over 35 years in the industry brings you. Comprehension. Of a lot of things.

Mister Magoo
Mister Magoo
2 years ago

The grandparent simply does not have the same viewpoint of the battlefield that you do. Pull your head in just a bit.

Sander
Sander
2 years ago

Let me check your comprehension of my comprehension: I did my first C programming in 1988 or so. Pascal before that. And assembly before that (1985).

Willy
2 years ago

You mean compared to PL/1, assembly or COBOL maybe ? Because C was the language the systems and tools were written with by then. When communication tools started to appear with the growth of the internet, C was used to write most applications. Mail clients & servers, IRC clients and deamons, browsers & web servers, news readers & servers, and of course, all CGI applications were all written in C because the above languages weren’t made for this. Perl started to displace C for CGI applications as it was easier (and trivially exploitable most of the time due to unreadable… Read more »

Sander
Sander
2 years ago

C/C++ was king in the 1990´s, but then came Java as absolute king in 2002, and then C rose again in late 2000´s.

dgp
dgp
2 years ago

I haven’t read the whole thing but based on your write up I’m sceptical that there is any realworld insight to be gained. Even in the highlevel VM based languages like java you wouldn’t be writing these micro functional blocks in the language itself as you should have decentish compiled versions of those things provided already. Otherwise what’s the point? Python is basically hot glue over C libraries in a lot of cases. I doubt it makes a huge amount of difference for a lot of use cases. And the use case for these languages tends to be different too..… Read more »

Frank Earl
Frank Earl
2 years ago

It’s somewhere between their take and yours. Seriously. It’s premature optimization for most cases, to be sure- but there’s a lot more done in Perl and Python than ought to be and I consider some of the inefficiencies they “measured” to be a lack of comprehension of the language and proceeding to implement something as if you’d do it in C. Lua’s not that inefficient, for example- you couldn’t use it in games as a scripting language, for example, if it were as “bad” as they’re describing there. Some of that you talk to- but you kind of gloss it… Read more »

Frank Earl
Frank Earl
2 years ago

The closer you get to C in that hierarchy there in their study, the more efficient you got. This doesn’t get into the relative merits or issues (and there ARE in many of them) of the various languages. They just proceeded to implement <X> and then tested it, without contemplation of the features of the languages in question. After having learned, and professionally used over 20 programming languages over the 35+ years in the industry, there’s good choices, good fits and poor ones. Both in terms of developer efficiency, system efficiency, scale out, etc. It’s a bit of an indication… Read more »

dgp
dgp
2 years ago

>inefficiencies they “measured” to be a lack of comprehension of the language

Or they knew that but the findings would be much less *interesting* if they benchmarked a full real world app written in C against basically the same app implemented as Python glue over mostly the same C libraries.

Willy
2 years ago

Actually, one of the problems is that people tend to either consider the micro-benchmark case or the big picture, but not how time is spent in applications. The reality is that most extremely slow applications suffer from either: one horribly inefficient operation implemented by hand because there was no other option or deep data propagation through many transformations due to objects inheritance that allow to access some data in the least direct way that looks more like a maze than something natural. Very often applications are considered sufficiently optimized when unit tests show acceptable wait time. But 100ms to compute… Read more »

Tim
Tim
2 years ago

I tend to agree. We have always done UI in VB because it’s painless, and everything else in C or assembler.

Willy
2 years ago

That’s the best approach, but it’s quite rare because it requires more skills. Congrats for this 🙂

TonyT
TonyT
2 years ago

We once had a system with the real time part written in Verilog (FPGA) and C (DSP), then a level of C code on the x86 PC for basic operations, and the UI was VB with a COM link to Python for easily customized program logic. It all worked pretty well.

Shubham Trivedi
Shubham Trivedi
2 years ago

Informative article

Thanks

Shane R
Shane R
2 years ago

What about .net core 5?

Vis10n
Vis10n
2 years ago

I am well aware of how much heating javascript causes, I can close tabs in my browser for the fan to stop and have many 100MB’s released each time. Javascript’s natural habitat is the web browsers and html needs to be rendered at the end. We need a richer set of default web controls and frameworks renderable by the OS in the browser so that the endless javascript frameworks and abstractions are not needed as much.

Rochus
Rochus
2 years ago

> in a paper entitled Energy Efficiency across Programming Languages published in 2017

The group published an update in 2021: http://repositorium.uminho.pt/bitstream/1822/69044/1/paper.pdf

Frank Carver
Frank Carver
2 years ago

Many thanks for that. All this is quite close to the area of my PhD research, and I wasn’t aware of the 2021 paper

Rochus
Rochus
2 years ago

I took the data from the tables given in the paper and made some additional evaluations based on the geometric mean of the time data normalized to C, see http://software.rochus-keller.ch/Ranking_programming_languages_by_energy_efficiency_evaluation.ods.
Interestingly I get a different order than the one in Table 4 of the paper. The paper seems to have used arithmetic instead of geometric means, which is questionable given http://ece.uprm.edu/~nayda/Courses/Icom5047F06/Papers/paper4.pdf.

Rochus
Rochus
2 years ago

> in a paper entitled Energy Efficiency across Programming Languages published in 2017

The group published an update in early 2021. Here is the link (scrambled because apparently links cannot be posted here): repositorium.uminho.pt slash bitstream slash 1822 slash 69044 slash 1 slash paper.pdf (prefix with the http stuff and replace “slash” by character)

Codrut R
Codrut R
2 years ago

but this means killing of poetry… as latin, as Perl…

Tuff Pro
Tuff Pro
2 years ago

How did Go used so much CPU?
There is something wrong there because every script i did in Go had a good CPU and memory usage.

ClownWorld
ClownWorld
2 years ago

Compared to what?

2 years ago

So is Rust’s, there have been discoveries of rather substantial improvements to such common algorithms, but they are not so obvious and I doubt that they are all in there.

As for Go, this is often cited: https://blog.discord.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f

Willy
2 years ago

You probably mean “good enough for you”. For plenty of tasks it’s generally better than interpreted languages, but I’ve seen some people use it for network tools or log processing and it lacked at least one digit compared to regular C code.

Bryan
2 years ago

I wrote a milter to subsample bounce messages based on MySQL settings and fed the result to a ruby program. The milter was written in C with pthreads and never failed or crashed or ran out of memory. The ruby program had to use a sleep of one second to prevent it from crashing due to threading issues. Both programs were multi-threaded. I agree that bad programming practices can doom any project. But, when well written, C will beat them all.

chunga
chunga
2 years ago

Waouh, that means low level programming languages are more efficient than higher level ones…just kind of wheel re-discovery uh… Nothing about assembly language which should relegate C and C++ to the summits of inefficiency, and why not go to hexa code or directly in binary…good luck to program even if only a simple compression software. Maybe you should consider only the global cost of development, which is currently the only items all companies are focusing on. Yeah, develop a complex software in C, at the good level of security and user friendly, will be 5 times longer than in python.… Read more »

John Sellers
2 years ago

They didn’t look at Smalltalk, which they should have. Also, the OS used is a significant factor. Windows, for example, is forever indexing all of the time. Updates are measured in gigabytes. Hundreds of processes are going on all of the time. Applications are not self-contained and use resources from all over the place. Installing is an elaborate process when simply copying a self-contained application onto the computer as a simple file would be a much more practical alternative taking a few seconds rather than rebooting a machine many gigabytes in size and trying to resolve thousands of potential conflicts… Read more »

Scott Lamb
2 years ago

A key point about this study: it’s not a direct comparison of programming languages. It’s a comparison of implementations of The Computer Language Benchmarks Game challenges in a variety of programming languages. Some of the implementations are painstakingly optimized with SIMD and sophisticated algorithms. Some aren’t. It’s benchmarking N different programs written in M languages (where M<N) that satisfy a given challenge, not the same program ported to N languages. Which languages have high-quality implementations might say more about how obsessed a given language’s community is with this particular set of benchmarks and rules than the actual efficiency of the… Read more »

tkaiser
tkaiser
2 years ago

The usual ‘casual benchmarking: you benchmark A, but actually measure B, and conclude you’ve measured C’ 🙂

Farshid
Farshid
2 years ago

Oh yes, let’s reinvent the Erlang/OTP in C just to save CPU cycles (I bet that won’t be the case). Let’s waste millions of hours of programmers’ life, just to make a point.

Hayley Patton
Hayley Patton
2 years ago

Can you read graphs? According to the results you present, Go is less energy efficient than some “interpreted languages” like Dart, Hack, JavaScript and TypeScript (which all use JIT compilers, so I don’t know why they are classified as “interpreted”).

Hayley Patton
Hayley Patton
2 years ago

Also, please note that the fastest C, C++, Rust, and Pascal programs (at least) use a custom bump allocator, whereas the others use the standard memory management facilities of their language. While this might or might not be an acceptable choice for the problem, it is certainly abnormal, and doesn’t “generally” work.

Farshid
Farshid
2 years ago

A post that makes an environmentalist statement about computer energy consumption, but then end it by requesting donations via cryptocurrencies which is the number one contributer to energy crises in IT world.

Joe
Joe
2 years ago

Sorry, but this is ignorant of how Python is actually used. The compute-intensive parts are written in compiled languages, so the differences in power consumption are much less. The data are from irrelevant benchmarks in which an entire compute-intensive problem is coded in Python. No actual professional would do that.

Willy
2 years ago

> The data are from irrelevant benchmarks in which an entire compute-intensive problem is coded in Python. No actual professional would do that. I’m sorry but I’m seeing that all the time. A lot of admins use it to process logs or transform data, and they adapt to the slugishness to the point of finding it totally normal to wait 1 minute to average response times in 1 GB of HTTP logs or count the status codes, because, well, “for sure it should take time, it’s 1 GB after all, that’s 16 MB per second, wow!”. And this is not… Read more »

Mike
Mike
2 years ago

Who is this Frank Earl guy who’s so high on his own farts and 35 years of experience sucking codex?

Willy
2 years ago

Probably one who, like many of us here, started with real computers at a time when virtual machines were not even a name nor concept, and when you would declare DATA statements in BASIC to place native machine code for the stuff that you wanted to be fast, writing that code in assembly under the DEBUG utility, carefully copying the bytes, and calling them using CALL VARPTR(foo)… Yeah, old times. At least by then savings were measurable to the naked eye (or ear when you wanted to make sounds on a crappy buzzer).

Hayley Patton
Hayley Patton
2 years ago

Virtual machines like Pascal p-code didn’t exist then? Or even SWEET16 for Apple/Wozniak’s Integer BASIC?

Occam
Occam
2 years ago

Ahhh yes machine code in data statements.. thanks for reminding me. Those were the days 🙂

Emmanuel Goldstein
Emmanuel Goldstein
2 years ago

FYI the language is called assembly, not assembler. An assembler is a tool that translates assembly into machine code.

example
example
2 years ago

LOL, the author of MASM32 made this very mistake.

ade
ade
2 years ago

But in many use-cases, code in Python/Perl is just some glue/wrapper calls around libraries where most crical parts are written in C (e.g. numpy…). Besides, remember the Greenspun’s tenth rule : “Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp”.

Jason Merkling
2 years ago

I find declaring variable types exhausting. While I agree with everything in the article how about C and a similar being faster because it is closer to the hardware I just feel like the amounts of lost electricity are too minuscule. I couldn’t do many of the tasks that I need to do as a Linux server administrator and internet marketer without Perl and python. I use the python module scrapy and selenium webdriver (with chromedriver) to perform so many daily tasks it’s scary to even think about doing that stuff in something I’d have to compile everytime I wanna… Read more »

Willy
2 years ago

> I just feel like the amounts of lost electricity are too minuscule

Per user this is often true. But when you start to pack all that code into tens of VMs running on real hardware that fills datacenters, I can assure you that’s not the case. I’ve met several times people who had to change to a new DC because they reached their maximum electricity capacity. And when that happens, it’s too late to think “if I had known, I’d have hired a few more developers to rewrite all that in the background and made amazing savings”.

Willy
2 years ago

I’m delighted to finally see a comparison by energy, I’ve long been saying I would eventually try to produce something like this! Having seen performance ratios of 6000 between C and another language in the past on some algorithms really disgusted me about what we were doing with all these joules… I remember having showed some “normal” performance levels on certain things running on very small machines (like a USB-powered gl.inet machine running a MIPS at 400 MHz), and people were asking where the cheat was because they considered it impossible given that for the same task they needed a… Read more »

Matteo
Matteo
2 years ago

This is the dumbest shit I read today

David
David
2 years ago

That’s surprising that Go underperforms. I left the community because giving good free work to bad people doesn’t make any sense to me, not because I expected the implementation to be THAT deficient. The very simple idea at the beginning was to just knock the sharp edges off of C, add a garbage collector, and implement the Hoare “communicating sequential processes” paper so that Google staff would have something like a restricted C++ to rewrite all of the Python code in after Guido had left. You can always run your Python code in the Jython VM, though I don’t know… Read more »

Eric Dujardin
Eric Dujardin
2 years ago

Obviously C is cheaper than Python on a single run, but to develop a C program one needs way more iterations of compile-and-test than Python, due to the programmer’s friendly language and libraries. It’s about the same as for high-performance optimization, don’t spend (CPU) time optimizing code that isn’t expensive at run time.

willy
willy
2 years ago

While this seems to be true for most developers, actually for me it has always been the opposite. Having spent countless hours trying to make a very trivial python script serve a page and emit certain headers in HTTP responses drove me totally crazy. There are countless variants of the HTTP server, some easy to use but not extensible, and others that you don’t even understand what you have to feed them. Now I know what drives so much traffic to stackoverflow, I spent my time reading there and blindly copy-pasting junk to see if that allowed me to progress.… Read more »

back2future
back2future
2 years ago

Tesla autonomous driving software seems mostly relying on C++, Java, VHDL/Verilog, and Python. (Web design for interfaces PHP, CSS, Ruby, React, Truescript and SQL for database management)?
Think efficiency comes with priorities for workflow of expert or community tasks (and their sizes and intensity on interaction for development changes) and infrastructure dependencies (drivers experiences database, surrounding acoustics recognition vs. local computation abilities with AI based hardware).
Nonetheless multiples of 30-70 for speed comparison or energy consumption differences for executables are more than expected (on 2021 hardware levels)?

Simon Crown
Simon Crown
2 years ago

The basic idea is flawed. It doesn’t figure in the extra programming effort to write efficient C. This may be far worse than the runtime gains.

Willy
2 years ago

It really depends. I don’t count the number of times I wrote C programs for a single use because it took less time than the difference with another language for a single run (typically data processing). And when your applications scale you value hosting costs a lot, to the point that servers can quickly outpace your developers’ costs.

Yoss
Yoss
2 years ago

Computers (including servers) make up about 1% of the world’s energy demand.
Negligible

zoobab
2 years ago

“[…] in 2015, ICT accounted for up to 5% of global energy demand”
“By 2030, ICT is projected to account for 7% of global energy demand.”

https://arxiv.org/pdf/2011.02839.pdf

Most of the energy consumption is in the production of devices (grey energy), not in their use.

Yassine
Yassine
2 years ago

C is a low level programming language.
Python and the others are high ends, and encapsulates stuff for the programmer at a cost.
If you can afford that cost, go for it.

Jack
Jack
2 years ago

yeah sure, rust as efficient as c… I believe to this as I believe a wayland benchmark on phoronix: zero.

Willy
2 years ago

I looked at some asm out of rust. It’s pretty decent, really. The problem this language has is that it’s extremely strict and prevents you from doing what you want, which is also how the compiler can infer some simplifications and optimizations. So you spend 3 times more time trying to write your program in a way that pleases the compiler, which at this point makes me prefer assembly, which is way more readable than rust for me!

Carlos
Carlos
2 years ago

Yea but you’re assuming that the programmer takes 0 seconds to write perfect code…

What about the energy needed to keep the machine running…?

Willy
2 years ago

Huh ? That energy (when it exists) is proportional to the code’s inefficiency. When you can run you application on a sub-watt machine you don’t need to start the dual-socket octa-core at 400W for the same stuff. Just an example, my backup server, it’s an Armada385 with 1GB of RAM. It needs to have some decent peak performance during backups but is not used the rest of the time, so that hardware is perfect. It consumes around 2W in idle. I was suggested to use some horribly inefficient backup tools written in Go that simply cannot fit on this machine… Read more »

Clocking this site
Clocking this site
2 years ago

The author of this article seems to personally dislike Python. At least that’s the feeling I get.

Willy
2 years ago

Or maybe he only had to pay the power bill to make his opinion.

Salvador
Salvador
2 years ago

Like everywhere on this environmental statements about what should be done… they completely avoid the economics behind everything… there is no way to replace our energy infrastructure with green energy as today at a decent cost, and the same here… making and maintenance of complex C/C++ software isn’t economically rational for many cases.

Mtk
Mtk
2 years ago

I would compare the current world’s economics to a criminal activity. Damaging nature and environment just some people to live in luxury. To speak nothing about the enormous world’s debt that to the best of my understanding needs to be repaid by 4 generations ahead. It is said that many IT companies moved to this trend as well. Personally I am very disappointed by the current software trend to use more .NET, Python, Java … based products, quite disappointed experience with such products. Hope more programmers and software engineers will look what is important to protect nature and environment and… Read more »

back2future
back2future
2 years ago

Many of that generations ahead maintain employment structures, forcing them to build cookie pop-up messages and data tracking, that require attention, knowledge on ‘rebound effects’, time and energy, for making their livings, because that’s the way this culture of ‘economy first’ created law?

Salvador
Salvador
2 years ago

Economics is about being rational. If powering an entire country with green energy instead of other sources cost 3 times, then you are 3 times poorly on average just bc of being “green”. Energy prices affect every other price. If every program was made on C/C++ the energy consumption and other resources to develop all those apps will increase sharply, something not been taken in count in this article. Economics are about not being stupid. Smart environmental policies should focus on take the best balance between environment and energy cost, the same on software. Higher energy prices, like we have… Read more »

Mtk
Mtk
2 years ago

I my opinion, the time for balancing between economy and environment has passed long time ago. Currently, we see the devastation effects of climate change, disasters, increased sun’s UV radiation etc. If humanity does not want to live in an environment like the presented in a recent movie Finch 2021, very strict measures are required. The resources for developing apps in C/C++ are nothing in comparison to the resources users are require to have in order to use those apps. Just look at the old Window XP apps – great responsiveness, limited use of RAM, storage space … If an… Read more »

Salvador
Salvador
2 years ago

We always do the math. You are willing to be far more poorly just to be “green”?? Maybe you have enough resources to afford that.. not many.

Salvador
Salvador
2 years ago

The thing is, we always affect environment with any action, even green energy facilities have an impact! We always do that balance. We need to mix solar/wind/hydro facilities with nuclear. But we need the last one for now. And UE is closing them and they will have to reopen worst options to supply the demand (coal?) or prices will skyrocket. For the C/C++ comparison it would require a bigger research to determine hoe much energy we waste taking in count development costs and consumers waste at execution. But to be honest… how much energy current laptops use??? Very low, we… Read more »

Tim Bian
Tim Bian
2 years ago

What about Julia?

Ray Meh
Ray Meh
2 years ago

There is a reason different programming languages exist. They simply serve different purposes. For example, I would never try to implement anything OS related with Python, and for the same reasons, I would never choose C for many application programming either, it is simply a bad choice. Lets consider the dictionary/Map data structure needed for application programming. Trying to implement that in a language that does not support it inherently ( C ) is horrendous, inefficient and buggy. In addition, I certainly hate the fact that you are mixing up your preferences with saving the planet nonsense. You are making… Read more »

bkydcmpr
bkydcmpr
2 years ago

IMHO the trendy architecture and frameworks are wasting far more than the language alone. Trillions of instructions are literally turned into NOP equivalent to achieve the buzzwords like cloud and microservice …

Willy
2 years ago

totally agreed.

James MClay
James MClay
2 years ago

Electrical power and compute resources are something humans can produce more of in an increasingly efficient and clean manner. Higher level programming languages use more of those in exchange for saving something that cannot be produced – time.

Willy
2 years ago

That’s not always true. When some programs become popular and make 1 billion persons waste one second of their life, it’s equivalent to 30 years of a single person. And some badly written programs waste wayyyyy more than 1 second of life to their users during all the the time the program is used. Some are more like 1 second lost per second of usage, counting several hours a day (think browsers and fat javascript frameworks that make you wait long for websites to render). If the time lost in my life due to programs written in some languages totals… Read more »

James McClay
James McClay
2 years ago

I would absolutely love to see an elaborate web application written in C. I could die happy.

Willy
2 years ago

As I mentioned above, I know at least one bank application rewritten in C after JS had been a terrible performance and reliability failure. It then progressively moved some parts to Java for ease of maintenance, but the parts that rarely change remain in C since there’s no need to risk to introduce bugs just for fun. No need to die for this 🙂

zoobab
2 years ago

Save the planet, don’t use computers.

Khadas VIM4 SBC