For me, there is one single reason spaces are superior to tabs, and that reason is the most important: it ensures that you, the reader, are viewing my code exactly as I, the author, wrote it.
Consider this snippet, where tabs (⇥) equal four spaces (·) in my editor:
This matters more when the presentation is important, like I might write ASCII diagrams in my code, are have a large matrix with elements aligned, or similar.
This is the patrician way. Tabs for indent, spaces for alignment. Looks the same for everyone, no matter how big or small they want their indents to look!
If you want the parameters to be indented the same amount (why you'd want that, I don't know, but whatever floats your boat):
blah(
blip,
blop,
bloop
);
And anyway, 'you see the code the exact same way I saw it when writing it' has the following problems:
1. It doesn't help because you were writing the code, I have to read it.
2. It doesn't help because the way my brain works most likely isn't 100% interchangeable with how yours does.
3. It may even not be true because I may be using a different editor, a different editor theme, a different font, or, by golly, an entirely different monitor resolution.
That being said, I will agree with my sibling comments which recommend the combination of tabs for indentation and spaces for alignment.
Fixed pitch fonts and ASCII art are outdated; not even Dwarf Fortress relies on them anymore. You can sort of line up numbers, but you have to be careful to use U+2007 FIGURE SPACE (not U+0020 SPACE) and U+2212 MINUS (not U+002D HYPHEN-MINUS) to match the size of an Arabic digit. Code indentation only needs to be visibly bigger or smaller, and lining up words and formulae are jobs for TeX.
> the reader, are viewing my code exactly as I, the author, wrote it.
That's not a good reason, there are way too many writers with poor design sensibilities, so flexibility is better.
And in your example you'd use elastic tabstops so that a single extra tab would visually expand to align arguments for you if you like it, but not for me if I don't
Why should you have control over what indentation width I choose to use?
There are a bunch of reasons why I might want a narrower or wider tab width. Most obviously, screen real estate - I might be coding on a tiny device.
When you do indentation and alignment properly (tab for indentation, space for alignment, as others have said), it's formatted the way the writer wants, while also respecting the reader's preference for tab width.
Spaces for indentation is incorrect, pure and simple. And the war is not "won".
I'm following a junior who is working on a project where everything, including braces, is indented like that.
Some lines overflow on a 2k screen.
So stupid... And it requires much more effort than just indenting logically depending on the depth of the current block. You have to wonder why people do this to themselves and to their colleagues.
The solution to this is to NEVER align, and use tabs for code indentation. And if you do ASCII diagrams, do them in comments and align them with spaces (of course). Tabs ONLY from the start of a line until code. No mixing of tabs and spaces.
Please let go of that childish esthetic to align certain stuff with spaces.
The widespread adoption of code formatting tools has rendered the very argument somewhat pointless. I don't even know which identation most of my code uses - my editor autoformat takes care of that.
it amazes me to still see people making the same incorrect and long-debunked arguments, 20 years later. It's almost like these spaces people don't bother actually looking at the options.
Consider this snippet, where tabs (⇥) equal four spaces (·) in my editor:
Looks good.Now you open this snippet in your IDE, where tabs are set to two spaces:
This matters more when the presentation is important, like I might write ASCII diagrams in my code, are have a large matrix with elements aligned, or similar.