Save the planet Program in C, avoid Python, Perl
cnx-software.com
cnx-software.com
To give a data point, in 2021-era C++ it's approximately 3 years with a very large part of it being done by a single person (https://github.com/SerenityOS/serenity). How long would that take with python ?
That almost sounds like confusing goals with ways to me. Unless those very specific ways are your goal for some reason, if you were to "build a decent and snappy GUI operating system from scratch", you probably wouldn't end up with those things in it. You'd end up with something more similar to Oberon, Smalltalk, or VPRI's system (was it Frank or something like that?).
But I thought it was supposed to be "decent and snappy"? This requirement seems to ruin it quite a bit since 80% or so of your snappiness goes away.
I am talking about implementing a web browser. Writing a program that can load www.example.com and displays it, in at most a few milliseconds. Of course loading a bloated website will be bloated but that's because websites use a turing-complete language - if my web page has <script>while(true);</script> of course things won't go fast, but it doesn't matter, what matters is that we write an engine that is able to execute that "while(true)" and burns those CPU cycles as fast as possible (because then a "normal" website won't be much slower than the theoretical best it can do).
It's a (semi)well-defined problem: how fast can you do network requests, how fast can you parse the DOM, can you fetch content such as images concurrently, how fast can you execute JS, which is all benchmarkable. It does not matter than it's going to be slow when loading www.facebook.com ; what matters is that it isn't slower than it should be.
That's like writing a generic sort function: you care about the performance of the sort algorithm ; of course if people use a sorting predicate which does filesystem access for them it won't be fast but it is also utterly irrelevant to measuring how fast your sort is.
(These days no OS is going to succeed with end users if it doesn’t have a browser).
Why would that be interesting? They'd exist and consume the same amount of energy regardless of what they worked on...
But that said, the overhead of the engineers energy consumption is overhead that probably turns to nothing over the life of a successful project.
I really don't understand. They'd just work somewhere else and consume energy, housing and food. There'd be literally no difference.
I conceded, this is a convincing point.
To flush out the argument though, it was coming from the perspective of the system consisting of the firm+employees delivering a project rather than the system of the entire earth. I don't think the smaller scope overcomes the overall point, but you could perhaps see where there might be some merit to the distinction. It is just that that distinction doesn't really matter.
Theoretically, if you have fewer employees required to complete a project, then that project might use less energy. And if this holds true across the industry, then those non-employees _could_ be doing something more green. But equally they could doing something worse. And in practice for software, they would just be working on a different project or shipping more features or whatever, so it doesn't change the steady-state, even if a distinct project is delivered with lower energy cost. Even if all projects are more human-energy-efficient.
If two different implementations use the same amount of compute, but one took 10 times longer to design and ship, then it is a less efficient solution, no?
Those people (and their energy usage) could have been working towards solving some other problem or doing something else worthwhile.
We are in the midst of a serious crisis, we know the reasonable solutions we should be taking to avoid catastrophe, and we are collectively choosing to ignore them. It should be treated seriously. If we're going to joke about it, it should be dark comedy.
Can you create a web framework in C that has as many features as Rails or Django? And what's the power consumption of that?
Higher level languages do more stuff. It's not like Guido and Matz just woke up one day and were like "fuck your CPU".
Plus, compilation requires a decent amount of power, as shown in those graphs. Does every C/C++ project run perfectly with no bugs the first time?
Still curious what the power savings are... I'm sure they've done enough profiling to know their performance is increasing. But are they saving energy? How about the compilation cycles to get to where they are? The carbon footprint of the additional employees? Etc...?
When the code will be deployed on 10K-1M machines, compilation costs are noise. In fact, FB does all sorts of expensive optimizations to ensure that the deployed executables are as efficient as possible, and the effort is worth it many times over. I'm sure the same is true at Google and elsewhere.
We'd have to look at the details to see which one is more effective overall. Although my gut says that "not programming in C" is generally the correct approach for your average piece of software.
Some napkin carbon footprint math—a computer on for eight hours daily does ~200 kg of CO2 in a given year. An average human on the planet is doing ~7,000 kg. Which means the average human’s 8-hour workday is ~6.4 kg CO2.
Yeah, let’s pull out the abacus and the slide rule while we’re at it, in the interest of carbon footprints. /s
https://towardsdatascience.com/high-performance-code-pays-di...
"The climate crisis threatens human civilization on a grand scale and electricity is frequently produced from fossil fuel. Electricity is then consumed by the operation of computer code. Google alone used 12.8 Terrawatt-hours in 2019 according to its 2020 environmental report, more than many countries and more than several US states. It seems intuitive that improving code efficiency should reduce environmental impact. Does it?
The answer is not at all clear and must be considered on a system by system basis. The main reason is induced demand.
...it will take a centrally coordinated process at both national and international levels that can allocate energy to different industrial and consumer sectors and manage the energy production mix on behalf of the whole of society. Only then we can solve this problem in a rational way that doesn’t depend on luck.
In fairness, software companies aren’t power companies, it’s a little ridiculous to expect them to build their own generation. What we can more expect from them is to pay taxes, divest from fossil fuel companies if they hold securities, and hold their total energy consumption under a ceiling set by a regulator while the society changes the energy mix as fast as possible."
Different languages were made with a reason, and they solve different problems. Even Python can be efficient when your largest bottleneck is network or disk IO.
Nowadays we have Rust, which is slowly catching up to C speed, and sometimes even surpasses it.
C is a beautiful language when used in embedded space, where memory allocations are minimal. Once you start throwing mallocs left and right, you lose that simple elegance.
From that paper, only C and Pascal, are optimal for energy and memory usage.
And Pascal has memory safe strings with reference counting. C is just too unsafe. 70% of all security issues are caused by C.
C or any "so called" efficient languages are wonderful for their use cases. Python or Erlang have other use cases. We have all of those languages for a reason.
Anyway you can take my Erlang from my cold, dead hands.
Now I have proof it wasn't.
Thanks, C++.
That includes defects,
It's one of many reasons I like new compiled/vm languages like Go, Swift, Nim F#. You got the productivity of python, but near the performance of C. User wins, dev wins and planet wins.
From the best analysis it does seem modern c++ could be the optimal performance/energy/speed/safety choice.
And yes I'm a proud c/c++ programmer.
That stab is mostly aimed in the direction of C# and Java
one could argue, that programming languages that are more close to the mind are more efficient. At least when looking at 2nd to n-th order efficiency effects, not just pure runtime performance.
Could it have been even better in C? Probably, but it was a lot easier to conceptualize and properly choose the architectural features that made the difference using ruby.
These days I would have done the rewrite in golang, and had the best of both worlds.
Could we get something as flexible and expressive and ergonomic as React or Vue with the performance of WASM?
2) There is a gopher proxy for HN: gopher://gopherddit.com
3) Use CLI tools, avoid JS ridden apps. If so, download the video and use mpv offline. Many times less power wasting.
And honestly, that would be an improvement. The trend seems to be to write more and more applications in JavaScript with Electron [1], which I unrigorously assume uses 10 to 100 times the memory and CPU of an equivalent Python app (given Electron apps seem to most frequently make my fan spin or have some kind of memory leak requiring a force-kill).
[1] Now ranking higher on Google than the subatomic particle: https://www.google.com/search?q=electron (https://archive.ph/J2HYI)
I have no idea about memory consumption. I assume Python does better than Javascript there due to reference counting.
I suspect that Electron apps are so easy to create and run somewhat acceptably, that the trend is for the developer to add more bloat than would otherwise be there. So a very efficient runtime leads to developer laziness.
Well, that's how you judge a language. You write code in it, as opposed to writing it in some different language not under consideration.
But a much worse problem seems to be the fact that binary-trees is not much of a representative benchmark. It's mostly a benchmark of your memory management. Unless your programs spend 80% of their time managing memory, they'll probably not match the results of binary-trees.
it is trivial* to add C code to Perl, even when using XS, I guess it is as easy to do the same for Python
if you do heavy computations in pure Perl5 or pure Python you're doing it wrong by definition
*assuming you can write C
The Python (programming language) is. Ok, if you want to get pedantic you can talk about the language vs interpreter vs ecosystem? I'm not sure what you are getting at.
> It powers many many websites including Youtube. It's a full power limitless language.
Lots of things "power" Youtube. I'm not sure how that's important to point out.
Unless you want to do something crazy like run 2 threads at the same time
And this was such a scalability problem that Youtube decided to spend the unimaginable amount of pain and suffering to rewrite in C++.
A major problem with scalability at Google is that the CPU heavy stuff has often already been isolated and what is actually needed is a sort of ambient performance rather than just focusing on hot loops.
With the exception of shell languages (and its overstated even there), the description “scripting language” is usually wrong and at extremely deceptively reductive, even for languages where that was a motivating or at least early major use case.
> their energy savings come from the fact that the programmer is typically the only person who will be running it,
Even when languages are used for scripting, that's not true.
2. The specs for the transition are ready and it’ll happen next year. Target is before June. First long-lived Merge testnet goes live next month.
Ethereum was released in 2015. The first PoS cryptocurrency (Peercoin) was released in 2012.
But this won't last. Many energy sources and metals are peaking and I can imagine a day when efficiency will count heavily.