12

I just found out that I should be using 4 spaces and not a tab for indentation, MY WHOLE LIFE IS A LIE.

Comments
  • 1
    Eww spaces
  • 3
  • 6
    You SHOULD be consistent. Nothing else matters. Stick to one.

    Tabs are for indentation. You can control how tabs look (how many spaces are used to represent them in your editor), while also counting as a single character, making them a better choice in my eyes.

    Spaces are better when it comes to presentation. (Imagine declaring an object in javascript, but you want every key-value pair to look like a table, with each value starting at the same column in your editor).
  • 2
    Tabs can cause weird readability issues when collaborating on code. The style guide might dictate a single tab but the layout of the code might look fine with a tabstop of 2 spaces but really weird with a tabstop of 8 or vice versa. A code style that defines the indentation size is more consistent
  • 2
    @Demolishun Is this article for real?
  • 2
    Using tabs for indentation is the equivalent to training wheels for programming.

    Change my mind.
  • 1
    Who told you you SHOULD?

    IMO spaces are spaces and indentation is indentation. For me tabs are the way to go since they don't impose anything on the appearance, i.e. you have one level of indentation and you can make it appear 1, 2, 3, 4, 5 or even 8 spaces wide if you're so inclined - and that's without ever changing the code. Good luck doing that with spaces.
  • 1
    @kamen my IDE allows for that...

    Most do these days. It's easy to figure out what's an indent and what's not with regex.
  • 2
    If you care at all about accessibility, you will use tabs
  • 2
    @alturnativ That is kind of the definitive answer.
  • 1
    You mean you were asked to use spaces?

    You can use either, though I would prefer tabs anyday. What matters is the consistency within a class/file/project
  • 0
    You should use tabs for indents and a IDE that can convert between the two automatically so you can set up a consistent style
  • 2
    @sariel You mean you can present leading spaces differently without changing them in the file? If it's that, it's new to me and kinda cool, but I can see it leading to some problems.
  • 3
    no you shouldn't. and you should slap everybody who says you should.

    tabs are the one true god of indentation.
Add Comment