Tabs vs. Spaces in the 21st Century

March 28, 2011

It’s bad enough we don’t have flying cars yet, but we still have to keep rehashing this debate? A quick troll for the coding standards of popular open source projects/organizations reveals the following:

Space Cadets Tabularian Horde Agnostics

Android
Apache
Audacity
BOINC
Boost
Drupal
GIMP
Google
Handbrake
Inkscape
KDE
LLVM
Microsoft C#/.NET
Mozilla
MySQL
Ogre3D
OpenOffice
OpenSceneGraph
PHP
Qt
Ruby On Rails
SpiderMonkey
VLC
VirtualBox
WINE
WebKit
XFree86
zeromq
nginx
wxWidgets

Blender
GNOME
Linux Kernel
MediaWiki
Mono 
Pidgin
PostgreSQL
Stellarium
WordPress

Eclipse/Java  
Wireshark

If this (very unscientific) survey is to be believed, just over 20% of projects prefer to use tabs for indentation, not quite 75% prefer spaces, and maybe 5% could care less as long as you’re consistent.

Me, personally? I don’t much care either, as long as tabs are only used for indentation and not alignment. I get cranky if setting my editor to use a tab width of 4 makes it look like someone lobbed a grenade into the source.  The biggest argument in favor of using tabs for indentation is that it permits developers to configure their editor to use whatever ‘indentation quantum’ they want; but that cake is a lie unless they also scrupulously avoid inserting tab characters for the purpose of aligning text in the current line with text contained in previous/subsequent lines. A mixture of tabs (for indentation) and spaces (for alignment) is required to make this work.

TabsSpacesBoth

(Taken from the EmacsWiki, original comic by Steve Napierski.)

Many projects seem to have decided that it’s easier to ban tab characters altogether rather than rely on developers to configure their editors to use so-called ‘smart tabs’, where the editor inserts tab characters for indentation at the beginning of the line, but switches over to inserting spaces once the correct indentation level has been reached.

I just can’t believe that this is still a thing after a half-century of software development. Until some alternative like elastic tabstops is widely available, I’m guessing we’re not gonna see that flying car…

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: