Live data from Hacker News

The Tabs vs. Spaces war is over, and spaces have emerged victorious

xn--gckvb8fzb.com

111–120 of 238 posts

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#111
post #17

Earlier quoted context omitted.

Yes, this. Which the counter point is either, Don't align things, or use tabs for indentation, and spaces for alignment. And maybe you can enforce no alignment, but that's a hard fight to win. And as far as tabs for indentation and spaces for alignment, I've found no practical way to enforce this via tooling/linting. And a rule without enforcement becomes inconsistent, which is how we get files full of mixtures of sp…

Disallowing /[^\t]\t/ and /^ / is a good start.

These regexes don't solve what I think is one of the major common problems/complaints though: using extra tabs past the logical indent point as a shortcut to avoid typing so many spaces for alignment purposes.

To take this example from a sibling post:

  if (foo) {
  »   frobnicate(bar,
  »   ...........baz);
  }

Many people will wind up doing this:

  if (foo) {
  »   frobnicate(bar,
  »   »   »   ...baz);
  }
And then your alignment is all messed up if you have a different tabs setting.

Checking for that requires something more like a linter with a detailed understanding of the syntax parse tree.

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#113
post #62

Earlier quoted context omitted.

> so by using tab, one ... allows the developer to determine screen spacing to their comfort (Allow me to reply to this age-old argument with the age-old counter argument...) But you also have to decide at what point to hard wrap each line based on a max line length, and you can only do that based on some choice of tab size. Anyone with a different tab size preference would see the right column wandering depending on…

> But you also have to decide at what point to hard wrap each line based on a max line length I think that you should not be doing this, for the same reason that you should use tabs. It allows the user to select whichever hard wrap point (if any -- I generally choose to not have one) they prefer. But all of this sort of thing is pointless debate these days, when it's pretty fast and easy to preprocess the files to ma…

But you don't hard wrap at exactly the max line length anyway. You wrap at the somewhere sensible near the max line length. This is much more tolerable to size changes in indentation.

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#114

The choice isn't (tabs) vs (spaces). It's (tabs && spaces) vs (spaces). In the real world, there will always be spaces, whether used for indentation or not. Using tabs for indentation inevitably leads to a mix of both - which is, objectively, worse for maintenance and consistency.

And if people didn't align text, you could still make an argument that people use spaces to separate identifiers or otherwise tokens, therefore it's spaces vs tabs&spaces…

Tabs are for indentation, to align the beginning of the line, later on if you want to align text somehow, use spaces. You probably shouldn't align lines with different indentation (I align rarely so I can't remember ever to do that).

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#115
post #104

Earlier quoted context omitted.

Sometimes I remember a workplace system I used, where someone had set tabs to 8 space. I don't know why it was 8, but it was.

The VAX/VMS terminals we used at university to learn Pascal defaulted to 8 space tabs, on a 80 column screen. That certainly pushed some people towards using spaces.

I use 8-sized tabs with 72 columns in C. The human eye doesn't like moving all that much while reading and more windows fit one the screen even if it is annotated with git blame. In addition there is this argument from Torvalds, that you should mind your maximum nesting in a single function, which I also find useful.

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#116

Not that one more opinion in this endless war of opinion will matter, nor will it convince anyone, but I genuinely don't see the issue with "tabs for indentation, spaces for alignment."

Indentation is alignment

Indentation is columnization.

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#117
post #46

Earlier quoted context omitted.

Exactly. Indentation != spacing. And thats all the argument i need. I dont understand why people argue with consistent text layout for all-spaces. You can use tabs to indent and spaces to align after that, in most cases.

> You can use tabs to indent and spaces to align after that, in most cases. In practice this is difficult; since the characters are invisible by default, people will inevitably mix up the two. Looks like the industry standard is to give up and use spaces everywhere, unless strict and mandatory tooling exists.

That's on you though, in the editors I use they are visible and not just in my default IDE.

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#118
Edit: it got fixed, thanks to the author

I think with majority of TypeScript projects using Prettier, 2 is more likely to be the default[0]

The linked page literally says to ignore it [1]

> STOP READING IMMEDIATELY THIS PAGE PROBABLY DOES NOT PERTAIN TO YOU > These are Coding Guidelines for Contributors to TypeScript. This is NOT a prescriptive guideline for the TypeScript community.

4 is a historical thing used as a default for all languages in VSCode [2]

[0] https://prettier.io/docs/options#tab-width

[1] https://github.com/microsoft/TypeScript/wiki/Coding-guidelin...

[2] https://github.com/Microsoft/vscode/issues/41200

Edit: found the TS style guide at https://github.com/basarat/typescript-book/blob/master/docs/... , it should be the correct link

P.S. did send a mail to author hopefully they fix it

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#119
post #74
post #64

Earlier quoted context omitted.

I’d say that one’s approaching resolution, too. And 4 has won.

I use tab at three. And will do to the day I die.

A friend of mine worked at a place which used three column indents and now I’m fully converted

Re: The Tabs vs. Spaces war is over, and spaces have emerged victorious

#120
post #62

Earlier quoted context omitted.

> But you also have to decide at what point to hard wrap each line based on a max line length I think that you should not be doing this, for the same reason that you should use tabs. It allows the user to select whichever hard wrap point (if any -- I generally choose to not have one) they prefer. But all of this sort of thing is pointless debate these days, when it's pretty fast and easy to preprocess the files to ma…

But you don't hard wrap at exactly the max line length anyway. You wrap at the somewhere sensible near the max line length. This is much more tolerable to size changes in indentation.

That's is a much worse user experience. The slack has to be greater for more-nested lines. In other words, you're really just catering to those who have wider tabs.
Post reply on HN