Tuesday, June 07, 2005

Tabs vs. Spaces: What's a good programmer to do?

Tabs or spaces? Which to use? Do you set that option that says "Insert X spaces instead of tabs" in your editor, or leave it turned off?

This argument came up again for me recently at the company I work for (Snowblind Studios). I had been told to stop inserting spaces where tab characters belonged, and an all-to-common scene ensued wherein I espoused the tabs-are-evil mantra but had little memory of why that mantra was with me.

So I did a bit of research to put the matter to bed once and for all. Or, so I thought. Hah! What a joke. This is a religious issue if ever there was one. Want to see just how religious this argument is? Just check this out:

I mean, just look at all those posts? That's a flame-war if ever there was one!

A good clinical overview of this tabs vs. spaces can be found at this URL:
An excerpt from that article:

    Tabs in programming

    computer programming, the use of tabs for code formatting and indentation is an ongoing debate. Programmers are generally divided into two camps - those who use hard tabs in their code, and those who configure their editors to insert actual space characters when they press the tab key. When tabs are replaced to spaces in this way they are referred to as soft tabs.

    There are many arguments for and against using hard tabs in code. What can be said without doubt is that one early benefit of tabs, i.e.
    compression (see above), is now less relevant as storage is so cheap, and sophisticated compression algorithms can provide much greater benefits.

    External links

Other argument summaries:

Pro Tabs:
Pro Spaces
And yet more from the why_no_tabs page:

No comments: