Live data from Hacker News

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

xn--gckvb8fzb.com

21–30 of 238 posts

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

#21

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."

Every repo that tries that ends up broken. I've looked at a lot of them.

Also, any use of hard tabs breaks diffs, which should make tabs a non-starter.

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

#22
The war is mostly over because regardless of it you use tabs or spaces, the many modern languages use a code formatter and reformat to whatever is common. Languages that go with tabs are also now routinely mixing it with spaces for visual alignment and assume a certain tab width for total visual width enforcement.

On the other hand editors often now handle spaces as if they are tabs, even for cursor movement. So well. Both won?

I remember a time when people religiously claimed that both tabs need to be the way to indent but also that they have to be 8 spaces visually. I guess at least that war was lost since now even CSS allows you to change the number of visual spaces a hard tab has.

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

#23

Tabs are better, simply because you can view them as you like. Go obviously does this, and Haxe too (with default formatting options, even tho its configurable)

Spaces are better, simply because you don't have to worry if another developer is seeing the code different than you.

See, I can do it too. This is why there is an ongoing discussion. Because there is no clear cut answer, just opinions.

At least this article brings some data to the discussion.

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

#24
post #5

Earlier quoted context omitted.

This works until someone tries to vertically align something like a table or a line that is wrapped.

https://nick-gravgaard.com/elastic-tabstops/

Great, so now I need a special editor plugin, and a compatible editor just to be able to properly view code?

No wonder why spaces "won"

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

#25
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.

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

#26

Wait until you guys hear about fibonacci tab spacing: https://marketplace.visualstudio.com/items?itemName=ewic.fib...

This is the first I've heard of this, but honestly, I think this would be really good for beginners!

Generally, you shouldn't have all that many indents in your function. Using this would be a good visual clue to a beginner that maybe they need to break out their function into multiple functions.

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

#27
In the 90s, when I used various text editors like Ultraedit, Nedit, Pico, Nano, Vi, and my co-workers used Dreamweaver, Visual C++, Visual Basic, NetBeans

I was in the "TABs are superior" camp but only for the initial indention of code blocks.

But somewhere along the way, editors added features that let you see invisibles, and let you set up smart tabs so that you could hit tab, but it would interpolate 4 spaces (or whatever you set) into the document, and let you shift+tab back the indention or TAB the indention, but put in spaces.

More importantly, the mass of people who all coalesced on using the same editor in the web development sphere, Sublime then Atom then MS Visual Studio Code, has made it easier to just say "set your editor to do this".

I have changed my mind to using SPACES now because the editor lets me fake using TABS.

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

#28
post #5

Tabs are better, simply because you can view them as you like. Go obviously does this, and Haxe too (with default formatting options, even tho its configurable)

This works until someone tries to vertically align something like a table or a line that is wrapped.

This problem is solved by gofmt because it automatically aligns with spaces after the tab so humans don't mess up the whitespace

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

#29
The most important thing is consistency. I've become a huge fan of deferring tabs vs. spaces debates to an autoformatter. Set it; forget it; argue about something else.

This is most useful when applied ecosystem wide - no one in the Go ecosystem argues about tabs vs spaces, they just run `go fmt` (or more likely their editor is set to do that automatically) and move the #$@% on with life :)

Fortunately for me, newer languages tend to include a formatter in the core install/editor tooling - Go, Rust, Gleam, Dart, probably more I'm forgetting... I think Go pioneered this approach and I'm glad others have taken it as well.

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

#30
Completely agree: tabs FTW. I wish I could find the reference, but when dealing with mono-spaced fonts, readability is apparently enhanced with THREE spaces per indent. Now, good computer people hate non powers-of-two, so it's either 1, 2, 4, or 8 spaces!!!! I guess I'm not a good computer person, because my eyes find tab stops at '3 spaces per tab' just right.
Post reply on HN