28

Seriously for the life of me I don't know why anyone would choose spaces over tabs

Comments
  • 3
    For alignment.
  • 1
    @Gauthier explanation would help 🤔
  • 5
    @FitzSuperUser Different editor has different perception of how much indented a tab is. So, long ago, when you opened something that was written in editor A in editor B, the indentation can look different. That is why old coders use spaces, so that their code looks the same everywhere. And that is also why current editors offer to convert our tabs into spaces. So what you say tabs could be actually implemented as spaces in your editor.
  • 2
    @setyadi current editors also have the option to set the tab-width.

    I am a tabs guy too, so i really hate it that the style guide of python wants spaces only. Python is not yaml. Who is offended by tabs so much?
  • 3
    @darksideplease Never stopped me from using Tabs in almost all my Python code. 😂
  • 3
    I generally like to use Tab = 4 spaces in all my editors.

    For web dev, Tab = 2 spaces. The nested indentation gets insane if wider than 2.
  • 1
    @FitzSuperUser Sorry. Tabs for indent, space for align, is a common scheme. The point of using tabs is (among others) that different users might like different tab width. If you use tabs exclusively, aligning this won't work:
  • 1
    @FitzSuperUser Add to that the fact that most coding standards have a column limit, which only really makes sense if the tab width is defined. Having a tab width fixed for every dev kind of kills the point.
  • 1
    I love the surprises I get from tab formatting. Tried my way through 4,2 and 8 recently for something I got from GitHub, but alignment errors were everywhere.

    Then, I discovered that 3 was the setting the author had used. And since the editor I used (VS2015) doesn't remember tab setting per source file, I had to set it back to four to make all other projects decently aligned.

    And of course, for languages using offside rules instead of curly braces, the compiler needs to know the different tab setting for every file too. Yes, tabs are such fun because everybody has their own setting and nobody knows the difference between indent and alignment.
  • 3
    That episode in Silicon Valley lol
  • 2
    Python, Python is why
  • 1
    @XiovV if you're using a decent IDE or editor, it will have a setting that can assign a given number of spaces to be the result of pressing the tab key. Which is what any sane person would do. 7 is indeed a strange tab width number, but yes you can even set up your editor to make the tab key yield 7 spaces.
  • 1
    @XiovV Eh? You know that the tab/spaces debate is about what characters are stored, not about what keys are pressed. Whether you use tabs or spaces, you always press the tab key, never the space key.
Add Comment