Hacker News new | ask | show | jobs
by eterm 2550 days ago
What proponents of tabs over spaces miss is the fact that consistency is the most important thing.

Editors ship with spaces over tabs as default, so you should use spaces over tabs. You will be more consistent with others and reduce errors if people somehow haven't picked up your configuration.

Anything else is just fighting the tooling.

Without consistency (hopefully brought by automation) you will find team members struggling with merge conflicts that were unecessary and only brought about because of whitespace changes.

Since we started forcing prettier on stage we've seen a reduction in manual merge resolution being necessary.

And if you're using a tool anyway to apply this consistency, the decision just becomes the following, do you use the defaults or a custom configuration? Your life will be a lot easier if you just go along with the defaults, even if they aren't your first preference.

That's not to say you can't custommise anything (e.g. the default line width of 80 in prettier is too low) but you should have a very good reason to do so. And as others have pointed out, this isn't one of them because tooling can recognise spaces as tabs just as they recognise tabs and still adjust accordingly.

1 comments

> Editors ship with spaces over tabs as default, so you should use spaces over tabs. You will be more consistent with others and reduce errors if people somehow haven't picked up your configuration.

Actually, no, that's a very recent thing. Tabs were the default for decades in the vast majority of editors, particularly on Unix. Even today, if I fire up most vi implementations (I really only use nvi on BSD) tab is the default. Pretty sure this is still the case for vim and emacs, too, and might still be the case for other common text editors like nano.

There's no denying that spaces are far more popular now in general, but I'll have to draw the line at whitewashing history. I haven't been programming for nearly as long as many people here, but IME it felt like the mainstreaming of C++, which brought the Windows/Visual Studio crowd into open source, in tandem with Python[1], were responsible for the dominance of spaces. Even Java code eventually capitulated, where standard practice was originally all tabs owing to it's genesis at Sun. Unix-related software and open source was almost entirely tabs until the early aughts. You can look at the source code yourself, though it's not always obvious because tabs being tabs the indentation usually looks natural regardless of your tab stop.

As I mention elsethread, Linux, all the BSDs, etc still use tabs. Projects with a sufficiently long pedigree typically still use tabs.

(Says a user of JOE, still bitter that Joe relented and changed the default indentation to spaces a few years ago.)

[1] I always wondered how Python ended up standardizing on spaces. I was never into Python, but IIRC Guido preferred tabs. I'm sure there's a story behind it, and have an inkling it's related to the onslaught of developers who cut their teeth in the Windows ecosystem.

I'm not "whitewashing history" that's a bizarre accusation because I'm not talking about history, I'm talking about what you should use today.

Just because tabs would have been the right choice in the past doesn't make it the right choice today.

Lots of REPLs have or used to have problems with tabs.