Environmentally friendly programming

According to legend Steve Jobs once motivated his programmers to quicken the boot sequence of the Mac by calculating how many lives that would save when all those precious seconds are summed up over a year. This way of adding up saved time is perhaps more often used to point out how much time you waste waiting for things. Which in all honesty is a more realistic way to see it. But both views are pretty pointless. We all understand that no real lives are saved and those days, months or even years spent waiting can only be spent on something else if we could save it all in one go. Which we can’t. There is however another way to look at this when it comes to computers and programming…

A computer running a program will use more energy than an idle computer. Not that much, but more. Therefore, adding up time saved when optimizing code can be directly converted into lower power consumption. This is a very real effect and unlike the examples above, energy savings can be added up and have a very real impact on the environment and our lives.

This is where environmentally friendly programming comes into the picture. As an IT consultant I’ve come across (and sometimes produced) code that is far from perfect as far as algorithms and memory usage is concerned. Now, in your average program this might not be a big issue performance wise. On a modern computer, performing a linear search on a small collection might only take a fraction of a second longer than a more complex search algorithm and the user will never notice the difference. Therefor, lazy programmers and those rapidly aproaching a project deadline will typically chose the easy path and go with a linear search. But when this code is run several times each day by thousands of user, the fractions of seconds wasted and thus the energy wasted start to add up to something more noticable. Excessive memory usage is also a waste of energy and is often something that can be improved. Selecting all columns from a table when you only need some of them is often justified by reasoning that “you never know when you might need it”. But lets be honest, most likely you wont need it. This means the program will have to allocate and manage a little bit more memory than necessary. Waste of energy!

So, environmentally friendly programming is basically the use of efficient algorithms, restrained memory usage and generally applying all the good old programming practices used back in the days when computers were not so powerful and you had to pay for computer time. We still have to pay. Not with money and not right now…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s