So I've run across the issu of tabs vs spaces again and have decided to put in my two cents. A nice overview of the topics is given here, but I disagree with is final conclusion. The topic actually consists of three points:
- When reading and writing code, how many columns are indented when changing scope.
- When displaying the contents of a file what happens when the the ASCII char #9 is read.
- When writing code, what happens when you press the TAB key on the keyboard.
The "religious wars" are fought of point #1 as points #2 and #3 are more technical. I personally believe in the TAB key inserting the tab character (ASCII #9) for formatting code and here is why. If you mix tabs and spaces it can make reading code a nightmare because your tab-width might not be the same as the tab-width the other person used with spaces. Hence, stick to tabs only. And since tab-width, how many columns a tab indents, is a matter of personal preference a tab character indicates this much better in my opinion. The idea is not move in x-number of spaces, but indent because we are changing scope. This is what tab-character signifies, that way when the code is displayed, the exact number of spaces is up the the person viewing it, not the person who wrote it. If I like my tabs at 2-spaces wide and you like yours at 8-spaces then a tab can represent both. This I believe is the correct way to view them, its not a question of formatting but of semantics. A tab means changing scope, not insert spaces.
As a final plug for tabs, if I'm having to match someone's eight-space code its a pain to use 24-spaces to get indention level of 3. Three tabs is much quicker.