top of page

Green Coding

Updated: Jul 7, 2020

To cut the carbon emissions, programmers are cutting the code. Call it green programming.

Have you ever wondered whether sending an email has an impact on your carbon footprint? Or whether one particular website is worse than another from a 'green' perspective? Don't worry too much if you haven't, you're by no means alone. But OGN Daily thinks this is about to change. And it certainly should!

Take the story of Danny Van Kooten, a Dutch programmer, who decided to reduce his carbon output by no longer eating beef or flying. Then, five months ago, he made a change that had an even bigger impact - and it took only a few keystrokes.

Van Kooten is the author of a popular plug-in that helps website owners use the mailing-list service Mailchimp, reports Wired. Install van Kooten's plug-in and visitors can sign up for your Mailchimp list directly via a form embedded on your site. It's a handy trick and over 2 million websites now use his plug-in. However, it makes all these websites slightly larger by adding several thousand more lines of code. Every time someone visits your page, a server has to send part of van Kooten's code to their browser. Sending data to a browser uses energy; the less code you send, the less energy you use. So van Kooten decided to slim things down. He “refactored” his plug-in, making it more efficient, so now it sends 20 KB less data. Overall, the site would use a little less energy every day.

Of course, 20 KB is a tiny reduction. But what if you multiply this by 2 million websites? Well, very roughly, trimming the code reduced the world's monthly CO2 output by 59,000 kilograms, the approximate equivalent of flying from New York to Amsterdam and back 85 times. Wow! Not bad for two hours of re-engineering.

“The code thing has been by far the biggest thing I could do,” he marvels, “and it's crazy, because it takes a lot less effort than not eating any meat.” Van Kooten's light bulb moment is, you will be pleased to learn, is now being shared by web designers around the planet. They call it “sustainable” software design, and it's propelled by technologists measuring the energy budget of nearly every swipe and click in our information ecosystem. It's a target-rich environment as so much of our lives is spent online, and all tiny code adjustments stack up and become truly transformative.

Recoding our digital world to use less energy often makes it more pleasant too. Consider, say, all that ad code that bloats websites - megs and megs of crap. We hate it for spying on us and bombarding us with ads, but it also slows page loading to a crawl.

“It's constantly pinging servers; it's not very efficient,” says Tim Frick, founder of Mightybytes, a green web consultancy. “All of that information really adds up.” When the European Union's regulations forced US companies to remove some tracking code from their sites for European visitors, USA Today's homepage shed 90 percent of its data size and loaded 15 times faster, as the designers at Mightybytes reported. Someone needs to tell Mail Online! It's arguably one of the UK's most bloated websites and one of the most visited news platforms on the planet.

Even our throwaway habits can add up to a mountain of carbon. So, going back to the question about considering the carbon impact of sending emails, particularly all the little social emails we shoot back and forth - “thanks,” “got it,” “see you then.” UK energy firm Ovo examined email usage and - using data from Lancaster University professor Mike Berners-Lee, who analyses carbon footprints - they found that if every adult in the UK just sent one less “thank you” email per day, it would cut 16 tons of carbon each year, equal to 22 round-trip flights between New York and London.

If individual usage habits can make such an important difference, what about really juicy targets for carbon reduction like big infrastructure. Sixty-one percent of all online activity comes from purveyors of video. (Netflix alone accounts for 13 percent of it.) Bitcoin's annual emissions are roughly those of Sri Lanka. Or look at AI. Training a single AI model can generate up to five times the lifetime CO2 of a car, as research by computer scientist Emma Strubell and her colleagues has found. Those areas need efficiency overhauls - now.

But even if small design tweaks don't zero out the belching emissions of movies or bitcoin, they are still worth talking about. It's good to shine a spotlight on the CO2 footprint of our daily software - it makes the value of lower-energy code feel tangible.

What if websites ditched their tracking bloatware and ran badges boasting about their improved loading performance and lower carbon footprint? It might change your surfing habits and competitors could be green with envy.

Spread the word! It's easy to share articles on OGN Daily. Just click on your preferred icon below and ta dah!

bottom of page