Environmentally friendly programming

When someone talks about CO2 emission, we usually think about big industries, cars and light switches. We don't think about code efficiency. But "bad" code is actually bad for the environment.

A couple of days ago I read a post that made me think about programming and the environment. It's not a long post and i recommend all developers to read it. The conclusion of it was that:
If C++ would have been used instead of PHP [on facebook], then 22 500 servers could be powered down (assuming a conservative ratio of 10 for the efficiency of C++ versus PHP code), or a reduction of 49 000 ton [CO2].

In a small scale it doesn't matter much if you write inefficient code. But if you're working on applications/systems that will be run by a lot of people, especially in a server environment, the difference is huge. I'm not suggesting that we should super optimize our code, because code that is too optimized is often hard to maintain and might cause similar effects.

I've boiled my thoughts down to these two "guidelines", which at least I will think more about when choosing the tools for the next project i'm involved in:

1. Choose a language that is as efficient as possible without loosing too much of the ability to test and maintain the code.

2. Try to use the JVM or .NET. Optimizations of the entire platform will affect all languages that uses it. There is also a change of more efficient languages on that platform.

No comments: