IT··3 min read

Green Tech and Sustainable Development

Every line of code emits carbon -- what can we do about it as developers?

Code Emits Carbon Too

A single Google search emits about 0.2g of CO2. A ChatGPT query is about 4-5x that. There's research suggesting that training an AI model produces emissions equivalent to the lifetime output of 5 cars.

There are estimates that the software industry's total carbon emissions are comparable to the aviation industry. About 2-3% of global electricity consumption goes to data centers, and that percentage is growing rapidly because of AI.

Honestly, almost no developer thinks about carbon emissions while coding. I didn't either. (It's a bit ironic that we obsess over server costs but ignore carbon costs.)

The Concept of Green Coding

Code efficiency is energy efficiency. Reducing unnecessary API calls, implementing proper caching, optimizing images -- these all mean using fewer server resources, which means less electricity.

To get concrete: converting images to WebP reduces file size by about 25-35% compared to JPEG. CDN caching cuts origin server requests by about 85%. When these optimizations accumulate, you need fewer servers and consume less power.

But from what I can see, there are limits to what individual developers can do. The really impactful decisions happen at the infrastructure level.

What Are Cloud Providers Doing?

Google has committed to running all data centers on 24/7 carbon-free energy by 2030. They claim about 64% achieved so far. AWS pledged to use 100% renewable energy by 2025, though there's a gap between "purchased" renewable energy and "directly used" renewable energy.

Data center cooling also consumes enormous amounts of water. Microsoft alone used about 6.4 billion liters of water in 2022. Enough to fill about 2,500 swimming pools. As AI demand grows, so does that number.

I'm somewhat skeptical of cloud providers' "carbon neutral" claims. Many rely on purchasing carbon offset credits to balance the books, and whether that constitutes actual reduction is debatable.

What Developers Can Do

Here's a list of what's realistically possible.

Serverless architecture brings idle resource usage close to zero. It's more energy-efficient than always-on servers. Cold start issues exist, but for most services they're manageable.

On the frontend, reducing bundle size reduces power consumption on user devices. For global services, trimming 100KB from a bundle produces meaningful daily power savings.

Dark mode also saves about 30-60% power on OLED devices. (Who knew dark mode was good for both eye health and the environment.)

Realistic Limitations

Honestly, keeping these concerns from being deprioritized in business decision-making is hard. Tell a PM "this optimization will reduce carbon emissions" and you'll get "what's the ROI?" in response.

If it connects to cost reduction, you can make the case. But on purely environmental grounds, it's still a tough sell. Everyone talks about ESG being important, but it rarely factors into actual development decisions.

All we can do is gradually raise awareness that efficient code saves both money and the environment. Incremental improvement is more realistic than revolution, which is a bit frustrating to accept.

Related Posts