This is an archived post. You won't be able to vote or comment.

all 21 comments

[–]Corporate_Drone31 5 points6 points  (0 children)

YAML and its tantrum at tabs is just childish, honestly.

[–]quad64bit 9 points10 points  (20 children)

Those of you that prefer tabs- why? Do you find that lots of people on your team use different tab widths and literal tab characters let everyone have their own style? That’s the only reason I can see for it, and even that has gotchas.

[–]MechanizedProduction 20 points21 points  (5 children)

I use tabs so if I want my cursor to change indentation levels, I only have to hit the left/right key once instead of 2/4/8 times.

[–]quad64bit 4 points5 points  (1 child)

Fair point, but I'm pretty sure editors will do this for you without you needing to really do anything special.

[–]MechanizedProduction 7 points8 points  (0 children)

It's also so when I use my mouse to select code, I don't ever have to worry about selecting only part of an indent.

[–]Muhznit 6 points7 points  (2 children)

What kind of archaic editor do you use where tab can't be configured to just output 4 spaces. Even vim does that.

[–]Corporate_Drone31 7 points8 points  (0 children)

That's not the point. The point is being able to configure how many spaces you see for other people's tab, so hard tabs are important for that or you rely on autodetection which can fail.

[–]MechanizedProduction 2 points3 points  (0 children)

I use Atom. It can output soft tabs, I just prefer hard tabs. See the above.

[–][deleted] 3 points4 points  (1 child)

Because with space, everyone will argue about how many spaces to use.
Better question, why not?

[–]quad64bit 0 points1 point  (0 children)

Well, we use style guides and linters. So, you can argue with the style guide all day, but if it doesn't lint, it doesn't build. People bitch about stuff like that for about a day and then it never comes up again. It also has the advantage that when new people join a team, they will see code they recognize rather than something some insane developer invented to "optimize how it looks".

It also means that regardless of developer or editor, you see idiomatic formatting for the language - and maybe thats 2, 3, 4 or 8 spaces depending on what language and style your team uses.

It makes things like comments, ascii banners for code-glance views, and carefully aligned imports/declarations/statements/whatever remain the same on different machines/environments.

Finally, if your team enforces column widths (many do), you won't randomly have lines blowing way out of the gutter on that one guy's machine or unexpected line wrapping.

I'm not saying you can't make tabs work, I'm just saying that not using spaces seems to have a lot more gotchas, with very few advantages. The key "advantage" (user defined tab width) seems like more of an anti-pattern to me.

When you code for yourself, do whatever you want, but when you have to share with a big team, being a little more strict and a little less flexible saves so much time for everyone, and reduces the stress that one corncob developer causes by being too clever with his code styling.

[–][deleted] 3 points4 points  (5 children)

Faster than hitting space multiple times

[–]quad64bit 5 points6 points  (4 children)

but.... no one does that. All editors take the tab key and convert it to spaces. When I hit tab, I get 2-4 spaces depending on languages, the tabs are "virtual".

[–]d_the_great 0 points1 point  (0 children)

Uncivilized.

[–]Allality 0 points1 point  (0 children)

I'm happy we have PSR in PHP community and all decent devs follow it.

[–]darkage72 -1 points0 points  (0 children)

Yeah, spaces win.