Death to the Space Infidels!

Why can’t it just store the code in xml and render it on-screen according to the whim of each user?

Everyone is happy!

I’m a tab guy. It’s just more efficient.

Only us programming dorks would have this argument gleefully for the eleventy billionth time.

I use TABS, spaces are for old farts that use vi and emacs.

Give me my tabs and pretty colors in my fancy IDE all day long. Weeeeeeeee!

thanks for the code, very useful!!!

This is really a simple argument.

Any of the options will work properly if all developers follow the same standard.

Any of the options will fail miserably if some developers follow the same standard, but others don’t.

Only the third option, tabs for indentation plus spaces for alignment, will allow developers to change the number of spaces per indent to their personal preference without screwing up the code. A guy who likes 2-space tabs can set his personal view to be two spaces, while a guy who likes 8-space tabs can do the same. The code will still be perfectly indented either way, and using tabs+spaces even multi-line function calls will still line up no matter what your tabstop value is.

If you just use tabs, you still get the same benefit of not imposing one man’s personal tabstop value preference on all, but multi-line function calls will no longer be aligned for non-standard tabstop values.

If you just use spaces, you are forced to impose one man’s will on the crowd, like a new web developer who doesn’t understand CSS.

This is all in the theoretical world where people follow the coding standard. In that world, tabs+spaces is the clear winner. In the real world, where people always forget about the standard and screw up, tabs + spaces is just too darn complicated for some people to understand, increasing the likelyhood of nonstandard code. Spaces-only goes from being the worst option to a potential winner because you can at least override a non-standard tabs-user by automatically converting tabs to spaces on checkin. However, you could convert spaces-at-the-start-of-a-line to tabs just as easily, so there’s really no case where spaces are the winner.

Tabs are always going to win the day due to allowing fussy developers to view code in their own personal tabstop preference. Spaces just can’t do that. Spaces are great if you believe your personal viewing preferences are The One True Way, though, and you’d like to force everyone else to follow them.

TAB. End of discussion.

How do you shift multiple lines of text around if its indented with spaces? Does anyone really use spaces anymore?

I’ve never heard one good argumnent for spaces and I still haven’t today after reading this article and most of the comments.

Tabs provide the same readability, allow custom indentation levels at a per-programmer level, and stop people from wasting time doing worthless custom formatting with spaces to make arguments line up, etc.

People that use spaces to indent their SQL should be shot.

To clarify worthless custom formatting, imagine somone that uses spaces to make their formal and actual parameter lists line up with the open paren. If you change the name of the method, you have to manually change the formatting of the method definition and every call to the method. People that use spaces are usually noobs or don’t have enough real work to do and should be laid off :slight_smile:

Why not have version control that normalizes source code before check-in, then apply a user’s formatting choice on check-out? If all somebody does is muck with the whitespace, nothing actually gets checked in.

Sure, it wouldn’t be perfect - e.g. how do you handle long single line comments - but it would be better than listening to everybody belly-aching about spaces, tabs and bracket placement…

Spaces are: absolute, predictable, necessary, reliable, standard, WYSIWYG.
Tabs are neither of the above.
In an ideal world tabs might provide I see it as I like it, you see it as you like it effect and may also spare some typing.
In the real world tabs are used inconsistently by the humans and interpreted inconsistently by the tools most of the time.
There is still chance to get tab usage right if only one person (you) and one tool (your editor) are involved. Unfortunately, that’s not always possible. We work in teams, deal with third-party code, use multiple editors AND other tools.
On the other hand, it is absolutely trivial to get space usage right.
So at the end it is a matter of priorities. If you value consistency and reliability more than your personal convenience, you inevitably chose spaces. Otherwise (and I don’t criticize anyone about it) you might stick with tabs AND spaces.

BTW I always LOL when the amount of typing is used as argument related to programming. We are not typists – so it doesn’t matter that much. On average a programmer produces about 100 lines of code per day, or about 0.2 character per second. Compare that to 50 words per minute (5 char/sec?) that an average typist achieves.

I’m surprised no one mentioned an old classic:
a href=

Most programming editors allow YOU to define the number of spaces to display in a tab. Therefore one tab can equal 2 spaces, or 4 spaces or 20 spaces if you want to get pervy.

It annoys me when people use spaces, as I’m then stuck to seeing it their way. USE A TAB YOU MORON!

Tab once and save space!

Let’s play: what’s the smallest, stupidest thing that can incite controversy in nerds? This topic could very well win!

The universal assumption in all the discussion about tabs vs spaces seems to be that your text is always viewed in an editor where you can configure your tab width preference. But what about command line output, like more, grep, etc. This happens to be a predominant use case for me on any project, and tabs cause all kinds of chaos for that. Long live spaces!

Do ‘man tabs’. On a Unixy system with a good gnu foundation you’ll see that ‘tabs -4’ will adjust your terminal tab setting to every 4 characters.

Also, see ‘expand’ and ‘unexpand’ for automagically expanding tab characters to the matching number of spaces (or vice-versa) via piping.

If you can’t remember any of the above, try apropos tabs, which will give you the list of the handful of utilities on your machine directly aimed at dealing with differing tabstop settings.

Having to set up tabs in multiple applications may be a chore, but the tab width if used properly (ie, tabs for indentation, not alignment, see above) won’t mess up the representation of anything in your diff program if indeed you are too lazy to find the option to change it. The worst outcome is that you have to scroll more horizontally. As I said above, even if using tabs for alignment instead of spaces: if you are relying on alignment for semantic cohesion, you are already leaving a maintenance nightmare and timebomb in your code; it’s not necessarily a bug that your source code control diff program makes that kind of thing look ugly!

All that having been said, I find it very amusing how many space-zombies above rationalize their choice by saying it makes their code consistent, and yet vehemently disagree over how much indentation should be provided at each tab stop. Tabs directly fix that disagreement by allowing each developer to define their own preference. Inconsistency is a feature, not a bug! Does it also bother you that your fellow developers might be looking at your code in Inconsolata or Monaco or even gasp Verdana instead of the Courier New font you wrote it in?

The important is to have a program running, whether you use Space or Tabs.

But considering that people are going to look at your code after you, for maintenance or new development reasons, then no doubt it should look esthetically good.
For this, I personally prefer to use Space as it is more strict and more precise. Space gives you more control on how you want your code to look like.

Omar Abid over the last 5 days has been literally been SITTING on that F5 button to get that pureile ‘First’ statement in there.
Personally, when formatting my code, I conform to what the lead dev. or dept. tells me to do… Which is normally NOTHING :frowning:

I swear by Tabs and whoever disagrees offends me and my religion, and should expect a programmers’ Jihad.

We, the People’s front of Tabspacing have only one enemy, the spacers. Oh, and Tabspacian people’s front too.

We will not rest until all editors disallow more than one consecutive spaces. Our struggle is also know as Der tabspace kampf.

It seems like a lot of space fans seem unable to tell the difference between writing code formatted the way the reader wants it to look and code formatted the way the writer wants it to look.

Tabs do both, spaces only do the latter. Hopefully readers here are smart enough to realize that you should want the former.


Spacers don’t hit the spacebar, they rely on their smart IDEs for converting tabs to spaces when you write them. Then again, they also preach using spaces arguing it’s to help those using dumb IDEs, or even notepad :slight_smile:

The only valid use of spaces is to vertical align stuff (e.g. method parameters). I can surely live without that, but some people are religious about it, so more power to them.

I’ll probably be a Tabber as long as my IDE does not jump 4 spaces at once on arrow keys and hitting backspace deletes only one space instead of 4. Or 3? Or better 2? But only in the context where I did want to indent, of course (good luck at guessing that)…

I guess I’ll be a moron for life.