Hacker News new | ask | show | jobs
Our Code Is Harming the Planet, We Need Carbon Aware Design Patterns (hackernoon.com)
9 points by TakakiTohno 1339 days ago
14 comments

With all the bloat-tastic web sites there are these days... What if a browser or plug-in displayed a little animated "Electric Meter" icon, which showed how power-sucking the site you were currently viewing was? With a few customization options (title, colors) users could re-label it as "battery sentry", "bill miser", "earth saver", or whatever floated their boat.

Seems like something that could really appeal to Joe Average User.

Pointless animation on that page - wasting cycles - needless carbon spent. Vile hypocrites.
"Good for thee but not for me!"
This is not a code issue, everything that use power is harming the planet, but the solutions listed there are not to write better/different code but simply switch the times and other things that only mitigate the problem.

Anyway better than nothing.

I disagree. It doesn’t take 10mb of code to put a few lines of text to the screen. This occurs because:

1. Site owners want to track everything with really aggressive spyware.

2. Many developers are grossly incompetent and will blatantly tell you a few lines of text cannot be written to screen for less than a billion dependencies riding on the largest most trendy frameworks (plural).

That is millions of wasted CPU cycles per millions of users per day, which doesn’t also include the data centers than consume more power and water than the nearby city where people live.

People who decide to write big web applications that run on the cloud using Python instead of basically any language should be harshly censured.
I'm not sure about "harshly censured", but I have actually started looking at Python alternatives with the explicit goal of energy efficiency.

Another route I've been keenly pursuing is aggressively reducing download sizes in web apps I build: JS, images, HTML, CSS, the lot. No web fonts. I'm exploring Svelte as a means to reduce the JS component too, so client energy consumption due to JS ops is reduced.

These can all seem like trivial micro-optimisations, but "cloud computing" is a bloated monster. Billions of web app interactions per day and a few kB here and there soon add up.

Delivered by a page needing 4+ Mb for something that's mostly just text. Well done showing us how to save the planet!
It looks like most comments here ridicule the idea. I think it's something that for some reason is discussed more in Europe than in the USA.

Basically, the point here is that (1) if any given computation can be performed in several ways, and one of them consumes less energy, you should strive to use it, (2) if you can get a similar result by using significantly less energy, you should consider it.

The reason for that is the scale: at this point we can not ignore the fact that the number of computing machines in everyday use is so high that even small changes that impact a large number of them also impact the whole environment. So obviously we are talking mainly about biggest players mainly. But not only: if your small library or app becomes so popular everybody starts to use it, you can make a difference, too (plus your users will love you - nobody likes resource hogs).

Europe can start by ditching those idiotic cookie warning popups. I bet that alone can power a small country size of Denmark!
Here's an example of how an existing (and maybe the oldest?) language but with "new armor" can significantly lower the carbon footprint:

Writing Green Software - Is Our Code Unfriendly to Environment - https://dev.to/velydev/writing-green-software-is-our-code-un...

Drops in the bucket while data-centers burn most of their consumed power in cooling, ups bleed, and idle unused capacity before a single line of code is run.
https://dl.acm.org/doi/10.1145/3533028.3533308 A paper where the authors use machine learning (ML) to optimize latency and hardware usage of Apache Flink dataflow programs. There's a paper in preparation from the same authors where they're looking at ML to reduce energy usage.
Nice to see an article on environmental impacts but it seems to be missing the "approach" of simply using less energy.. For example:

1. Generating less logs & expiring them more quickly 2. Including fewer third-party SDKs 3. Using lower-resolution images & videos 4. Not encouraging people to buy unnecessary goods through marketing..

Clickbait title. The article is not about writing carbon-aware code, but about where to run large-scale applications.
As another poster said, that isn't a code issue.

You know what is a code issue though? "I dun need no optimazashun, I'm a faithful beleevur in Moore's Law, in the fuchur ppl will run my junk XD". Every single of those needless operations that your software does consumes electricity, without actually improving the life of anyone. Those will pile up because it isn't just you, it's software developers from the whole world doing this kind of stuff, with software run by almost everyone in the world.

It's fine to not care too much about efficiency when you're just solving some local issue with a dirty bash script, that you'll run exactly once and forget about it. However, software developers should have a bit more insight that needlessly wasting everyone's electricity.

Use compiled binaries everywhere! End the hegemonic AntiGreen opression of dynamic languages! ;) . CORE - compile once, read everywhere is here to save us
Use Nim instead of Rust and C++. Shorter compile times.
Problem: cloud computing is hurting the environment.

Solution: a new cloud computing service to add on top of your existing cloud computing services.

Brilliant.