41

Colleague: Oh i've noticed your PR uses tabs instead of spaces, we use spaces, can you change yours please?

Me: ..... can you leave the building immediately, for your own safety

Comments
  • 2
  • 2
  • 34
    It doesn't matter what style you prefer, one always uses the already established style of the codebase.
  • 18
    Use a soft-tab editor FOR FUCK'S SAKE
  • 3
    I read recently that people who use spaces are paid more on average… which makes total sense when I look at my bosses.
  • 0
    Eyeroll.
  • 2
    @devios1 because one group is better at making money, and the other is better at programming? 😃
  • 0
    @fdgram true, unless the existing codebase is wrong
  • 0
    @filthyranter well I need to use xcode and it doesn't have a soft tab option so I can't
  • 1
    @devios1 yes because the people using spaces force the good developers out of the company. When they are the last one left, they threaten to leave too unless they get a raise. Managers will make it happen for fear of loosing the entire team
  • 1
    For years now I've used tabs that convert into 4 spaces (2 for specific projects).
  • 1
    @Noob isn't that the only way to use spaces?
  • 1
    @Noob I'm confused as well. When you hit the tab button, does it insert 4 spaces, or insert a tab that is the same width as 4 spaces.

    The former is just using spaces, you just happen to be using the tab key on your keyboard as a shortcut
  • 1
    @practiseSafeHex you insert 4 spaces as you press Tab.
    Tabs won't always be the same width, so you can't anticipate them to be 4 spaces.

    @Commodore unfortunately I've seen people smash space 4 times.
  • 1
    @Noob 🤤🤤
    As far as I know, any decent text editor is able to convert tab to spaces (btw 4 spaces tends to be the convention in oop languages but js is leaning towards 2)

    How the hell can you work while mashing the space key?
  • 1
    @Noob This is the difference between soft or hard tabs.

    A soft tab editor will read the number of spaces you have set, and treat each multiple of those as a tab. When you hit the tab key, it will insert those number of spaces and display it to you as a tab. But when you look at the contents via git (for example) you will see only spaces.

    A hard tab is when the tab character is inserted. It is up to each editor or renderer to decide (for example) how many pixels width to make the tab display as. Most editors that use hard tabs (that I know of), give you the option of deciding how many <width-of-a-space-character> to display the tab as.
  • 2
    @Noob So if we were both using soft tabs, and I had mine set to 4, and you had yours set to 2. You would see 2 "tabs" everywhere I see 1. This would cause alignment issues down the road because as you start to insert tabs, there isn't enough spaces for mine to see them as tabs. Our code would end up all over the place.

    If we were both using hard tabs, and I had mine set to be the width of 4 spaces, and you had yours set to be the width of 2. We could both code away with our desired indentation widths, without pissing the other off, or causing merge conflicts.
  • 0
    @practiseSafeHex in that case your text editor should be smart enough to figure out the indentation width is 2 and configure itself to that in that file.

    The problem then becomes that you have to use 2-wide indentation which is a pain in the butt when you are used to 4-wide. The solution: tabs. They can be set to any width that _you_ personally like.

    "Oh but then alignment breaks because everything looks different for everybody". Easy solution: don't align things, it's unnecessary, or if you really have to, use spaces.

    Tabs for indentation, spaces for alignment.
  • 0
    @practiseSafeHex Now I recall reading about this some time ago.
    I use Sublime Text for all languages and it always uses 4 spaces when I hit tab.
    Guess it's set to soft tabs by default.

    Thanks for the detailed explanation!
  • 0
    @Commodore I don't know how someone can smash his space so many times. It seems redundant and tiresome.
  • 0
    This is why you have automated linting tools...

    Use whatever you want in your Ide and have the l'inter change it to whatever the repo has defined as standard...

    Problem solved, everything is uniform and everyone can use his style when coding...
Add Comment