No, your clean code won't save the planet
Need to channel my election anxiety into something productive, so here you go.
One baffling trend I'm seeing recently is people trying to moralize virtuous programming, like small websites and fast code, through appeals to the climate crisis. This is ridiculous. It's bad research, bad programming, and bad ethics.
Your local fonts aren't changing the world
The moral grandstanding first appeared a few weeks ago, with essays like Trying To Go Green With Local Fonts and This website is killing the planet. These pieces argue that serving a website costs electricity, so the more website you serve the more electricity you use. And that's obviously bad for the planet, right? If we slim down our websites we'll save the planet!
Let's pull a quote from one of them:
According to a website carbon calculator, this website emits the amount of carbon that 4 trees absorb in a year. And that’s just the homepage! ... Before changing to local fonts, the same calculator estimated that my homepage used around 9 trees worth per year. That’s a reduction of over 100KG of CO2 per year. I find that statistic mind boggling.
Wow, switching to local fonts saves 100 kg of carbon each year. Why aren't we all doing that?! Well, let's put his numbers in context. Those two posts used the website carbon calculator, which estimates that 20.25kg CO2 ≅ 47kWh electricity and that the Internet globally consumes 416 TWh per year. Plugging the numbers in the Internet then emits 180 billion kilograms of CO2. So the author, by switching to local fonts, reduced the carbon emissions of the Internet by 0.000000056%. Assuming he gets 10,000 visitors a month, which most personal websites don't. This change is meaningless.
How meaningless? According to the Carbon Fund you can offset your CO2 emissions for $10 per metric ton.1 The author saved the equivalent of one US dollar per year. One whole dollar. Assuming he gets 10,000 visitors a month.
The Internet does use a lot of electricity, producing some 0.6% of world emissions assuming the carbon calculator's 416 TWh numbers are correct. But almost all of that is streaming video and playing games. Netflix, by itself, consumed 15% of the Internet bandwidth in 2018. Your personal website doesn't matter. Stop flagellating yourself over it.
I'd like to point out that I don't trust the "website carbon calculator". It's probably overestimating the amount of carbon your website consumes. The creator is A WordPress consulting agency whose very first tip for making your website more energy-efficient is this:
SEO might not appear to have anything to do with website efficiency but in practice the goals of SEO are inherently aligned with the goal of reducing energy consumption. When optimising a website for search engine rankings, we are helping people find the information they want quickly and easily.
Does that sound like someone deeply committed to reducing emissions? Or does it sound like someone who found a good marketing stunt? I wouldn't be surprised if they were putting their finger on the scale to make websites appear to admit more carbon then they actually do. Maybe shave a bit more off that ten-millionth of one percent figure.
You're all getting utilitarianism wrong
This week we got Is it morally wrong to write inefficient code?, which tries to lay out the case that this is a moral question:
In this post I will explore the idea that because running code contributes to global warming, writing inefficient code is morally wrong.
Same argument as before: code costs electricity, inefficient code uses more electricity, so inefficient code causes more global warming. The post is about "reducing suffering", an implicit use of utilitarianism he makes explicit in a forum discussion. Utilitarianism is broadly the moral philosophy where you want to maximize the most good for the most people. I'll set aside the question of whether utilitarianism is actually a good moral philosophy or not and instead focus on whether this post is using utilitarianism well.
Now let's crack open John Stuart Mill's Utilitarianism:
defenders of utility often find themselves called upon to reply to such objections as this- that there is not time, previous to action, for calculating and weighing the effects of any line of conduct on the general happiness. ... The answer to the objection is, that there has been ample time, namely, the whole past duration of the human species. During all that time, mankind have been learning by experience the tendencies of actions; on which experience all the prudence, as well as all the morality of life, are dependent.
Mill glazes over the objection, so let me emphasize it. If our goal is to maximize utility and minimize suffering, then in order to determine if a specific action is moral or not we need to accurately measure its utility. And that's really hard. If I make the code faster, and so more people use it, have I increased emissions? What if the increase in emissions is balanced out by happier users with more utility? And what if one user is so happy they use your code to launch missiles at innocents? And what if you're a brain in a vat on Twin Earth in a runaway trolley?
Mill can sidestep this question because it's not one he's interested in. His goal isn't to measure the morality of individual actions, it's to argue the moral basis for a harmonious society. He aims to show that the premises of utilitarianism, considered as principles, naturally lead to justifications for liberty, impartial justice, and suffrage.
None of this means that you can't apply utilitarianism for individual actions. Mill wrote his book 150 years ago and doesn't have a monopoly on how we apply his ideas. But you should recognize that action analysis is a really hard problem that was intentionally avoided in the founding text, and it wasn't something Mill wanted people to do. If you want to say "this specific action raises utility", you better be able to make your case watertight. It needs to be beyond all reasonable doubt.
And "faster code uses less electricity so emits less carbon" is not beyond all reasonable doubt.
Why do people do this?
Why all this moral grandstanding, anyway? Why's everybody suddenly so into saving the world through programming better? I can think of a few reasons:
- People feel paralyzed by the ongoing catastrophe and want to use their technical skills to make a difference. Writing faster code is using your skills, right?
- It's really trendy to save the planet and people want to get on the bandwagon.
- People see certain code qualities as inherently virtuous and are using global warming as a way to justify that virtue.
- It's good marketing.
The least cynical of these is (1), but it's still a frustrating reason. It means that people are jumping in and trying to help without having done the research on how they can best help first. I guess that's individually fine. It still bothers me personally, though, when they then share what they did with others as a means of inspiring others to do the same. Then more people end up doing something that doesn't help at all.
Maybe I shouldn't be as frustrated about this as I am. I dunno. I just spent two hours crunching numbers and rereading Utilitarianism to write a newsletter post. Is that really any better? I guess I'm not trying to save the planet with this, so that's one difference. And I'm telling you that you don't have to feel bad about not using local fonts.
Update for all the website readers
This was sent as part of an email newsletter; you can subscribe here. Common topics are software history, formal methods, and silly research dives. Ranting on it is actually pretty uncommon; I wrote this rant primarily as a vent for election stress. Updates are 1-2x a week with the first being public and the second (usually) being email-only.
I don't think these numbers are fully accurate, and I know there's a huge controversy on whether carbon offsets actually do anything. I'm just using this to get a sense of the monetary scale. ↩