6 ms·
Spaces over tabs is one I don't understand - it's the most democratic way to format code (and it saves redundant bytes of code).
by below43 2y ago
Spaces over tabs is one I don't understand - it's the most democratic way to format code (and it saves redundant bytes of code).
- zamalek 2y agoMomentum wins over superior solutions all the time. Just like SMTP, I feel like that tabs vs. spaces is a lost war.
- antisol 2y agonope
- bheadmaster 2y agoThe 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.
- jgalt212 2y agoIn a world where tabs win, you then have a battle over how far to move the cursor which each tab.
- 1317 2y agono, because then everyone can set it to display how he likes
- maxhille 2y agoIn the tabs world this is just a style set by whatever displays the code, eg. the user's editor setting. In the spaces world, you have the battle over how large indentation should be and everyone has to live with what someone else chose.
- antisol 2y agoit 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.
- dlivingston 2y agoFor 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: if (someCondition) { ⇥ Foo foo = SomeClass::SomeFunctionCall(myParameter1, ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ··myParameter2, ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ··myParameterN); } Looks good. Now you open this snippet in your IDE, where tabs are set to two spaces: if (someCondition) { ⇥ Foo foo = SomeClass::SomeFunctionCall(myParameter1, ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ··myParameter2, ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ⇥ ··myParameterN); } 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.
- rawling 2y agoOnce you're not purely using tabs to indent but also throwing spaces in there, why wouldn't you do it like this? if (someCondition) { ⇥ Foo foo = SomeClass::SomeFunctionCall(myParameter1, ⇥ ······································myParameter2, ⇥ ······································myParameterN); }
- malicka 2y agoThis 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!
- erik_seaberg 2y agoFixed 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.
- tmtvl 2y agoIf 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.