Comment by Sharlin

5 days ago

Well, the tabs vs spaces had been mostly resolved and spaces won. But obviously it was never about what physical keys to press, nobody on the spaces side would spam the space bar to indent stuff (except maybe in the unfortunate situations of having to use an editor with no choice of setting the tabulator to emit spaces, or a textfield in a non-editor UI where the tabulator cycles the focus instead).

I'm still in the "tabs for indentation, spaces for alignment" camp. If you adhere to it, it makes your code look nice on any tab size.

  • For a solo project, sure, you do you. But for any meaningful collaboration, deliberately mixing tabs and spaces - and relying on a manual, semantic convention to use them the "right" way - will inevitably lead to a maintenance / consistency nightmare.

    • To add to your comment, it's kinda common to find projects that have spaces and tabs improperly mixed in the indentation. Making a quick search among the projects I have cloned, I'm seeing indentations like

        tab * 4 + space * 7 + tab * 2
        tab * 2 + space * 1 + tab * 1
        tab * 1 + space * 4 + tab * 2
        space * 16 + tab * 3 + space * 4
        tab * 4 + space * 2 + tab * 2 + space * 2
        tab * 3 + space * 3 + tab * 1 + space * 6
      

      The code ends up looking janked unless you use the particular tab-width of the space/tab-indenter[1], which isn't always 8. It completely defeats the whole purpose of the tab indentation.

      [1] On those first 2, given the odd (not even) number of spaces, it's likely that use of spaces was for alignment, but then a tab-indenter added tabs to that...

Typing formulas in Excel

It's too bad spaces won, tabs is just correct I think, since one can configure the tabstop to use any indent size they would like. I'm quite tired of reading 2-space indent. Seems everything has moved this way now except python. I'm even seeing C with it, which is especially jarring. I think the languages that use braces for indentation particularly need 4. Python needs it least, and I can read Ruby because its blocks are delimited by words and it's bad style to write long methods

  • Agreed, four is optimal and has luckily been the standard in projects I’ve worked in. Encourages you to avoid deep nesting as well.