What most of these discussions leave out is that you can't just say "use spaces instead of tabs."<p>You have to say <i>how many</i> spaces.<p>Is it 2? 3? 4? 8? How many?<p>If you use spaces, you are committing to say how many will represent one indent. And please take note of how your choice affects the visually impaired programmers from the Reddit thread. Or someone like me who finds monospaced fonts hard to read and proportional fonts much more legible.<p>But why do you even need to say this? Why should it matter how many spaces represent an indent level?<p>The only time it really matters is when you not only use indentation, you use <i>column alignment</i>, like this:<p><pre><code> myFunctionThatDoesStuff(someArgument,
andThisCalculatedOne(anArgumentThatMeansSomething,
anotherWordyName));
</code></pre>
This style is mandated by many coding standards, including Google's C++ standard. If you use an alignment-based style, you had better use spaces, or else you are in the "tabs for indentation, spaces for alignment" muddle.<p>What would happen if you abandon column alignment and use only indentation:<p><pre><code> myFunctionThatDoesStuff(
someArgument,
andThisCalculatedOne(
anArgumentThatMeansSomething,
anotherWordyName
)
);
</code></pre>
Here the parentheses are treated just like curly braces: if you need to line stuff up, don't do it at whatever column things happened to fall on, do it by indentation only. That's how we code curly brace blocks.<p>Now your code will be just as readable if it's indented with tabs, or with whatever number of spaces you like.<p>If we coded curly brace blocks the way these standards require us to use parenthesized expressions, our code would end up looking like this:<p><pre><code> if(someBooleanExpression) {someFunctionCall();
if(anotherBooleanExpression) {doSomething();
doAnotherThing();}}
</code></pre>
Do you code like that? Do you <i>want</i> to code like that? Then why do you format code like that (if you do) simply because the delimiters happen to be parentheses instead of curly braces?<p>If you stop using column alignment, and start using indentation instead, so many problems go away. Space indentation (and how many spaces?) no longer has any advantage over tabs.<p>I sometimes wonder why so many coding standards mandate column alignment. I think it is because people get tired of talking about it and say "we must agree on <i>something</i>, now! And we will stick with it forever."<p>I've been in these discussions, and what happens is whoever is most "passionate" about their particular style gets their way. And that will usually be the person who is fussiest about these things, the person who loves fiddly column alignment. Why else would such an impractical approach be baked into so many coding standards?