2009-04-13 21:06:29 PeterBraden.co.uk

One of the great battles of computer science has reared its head again. Yes, Coding Horror resurrects the perennial Tabs vs Spaces conflict.

One of the arguments that is often jocularly thrown into the fray is that tabs are greener than spaces. And having just read a book that takes an objective look at this sort of soundbite statistic, I was quite ready to put on my imaginary figures hat and solve this battle for good.

Let's assume a cost of 7kWh to move 1Gb . That means the cost of using spaces over tabs (assuming 4 spaces per tab; ignoring dictionary compression techniques) is approximately 1.95E-8 kWh per indent, per read.

Now let's estimate how many indentations we're talking about. I'm going to assume an average of 2 indents per line on a typical project, and we'll use the standard 70 LOC per programmer per day estimation (probably way under, but most of these numbers are imaginary, so whatever). This means, assuming that we have around 6 million programmers in the world (I made that up. Apparently there were 180,000 in 1973 so it seems pretty reasonable) that we are producing 420,000,000 LOC per day and thus 840 million indents.

Now let's assume that each of those indents is going to be read 100 times per day. 84B indent costs per day. Thus we can see that the energy cost of using spaces instead of tabs adds up to 16,380kWh per day. That's the equivalent of 409 additional cars on the roads.

Programmers: by using spaces you are destroying the planet!

(And seriously, if your editor can't display tabs with your preference of spaces then your editor sucks. I don't care how l33t it makes you. Tabs FTW)