3

What's better tabs or spaces ?
I don't know the implications of each.

Comments
  • 1
    Have you learned nothing from Sillicon Valley
  • 2
    I'm not sure which one's better, but it's great fun to argue about!

    (I use spaces as most text editors will display them properly)
  • 3
    I usually use tabs. It's easy to instantly change the amount of spaces a tab should display in any good editor.
  • 1
    But supposably there's something dangerous about using tabs, and I wanted to know what it was.
  • 2
    They have zero implications. Just another holy war.
  • 3
    Tabs or spaces work fine, so long as you're consistent. However, I will always argue in favor of spaces.

    Tabs make code more difficult to read on e.g. github because you cannot change their width. They also make aligning difficult for non-multiples of tab_width (ex: multiple declarations of type char, multiline array literal within a comparison, etc.). Tabs lead to other readability issues as well, and there are usually ways to avoid them, but not always.

    Of course, everything also turns into a giant unreadable disaster if devs mix tabs and spaces, so consistency is more important than your choice.
  • 1
    @Root gofmt indents with tabs and aligns with spaces. And since everyone uses it, there can't be ambiguity for go code. Javascript though is a different beast 😨 I also stumble upon files in the codebase that were written using different editor settings (exactly because they have spaces, which is 2 spaces but I like to see them as 4, so I need to reformat)
Add Comment