Hacker News new | ask | show | jobs
by markbnj 3826 days ago
Interesting! I assume tabs being so common in C projects has to do with their use in makefiles. But what is up with Go? Why are tabs used exclusively there? Not a Go programmer so I assume that must reflect something in the language or typical tool chain.
4 comments

In case of C it's not just makefiles, in fact I would guess that the reason makefiles use tabs is because there is a historical preference for tabs in C programmers (just a wild guess really). Various C style guides mandate the use of tabs for indentation (and spaces for alignment), for example FreeBSD's Kernel Normal Form Style[0] (which is really an older standard going back to how K&R formatted the code), I think other BSD's use a simmilar style, and Linux kernel coding style[1].

I'm not old enough to know personally, but I have a feeling tabs were preferred in the old days in general at least on Unix platforms. Some of that sentiment might have spilled over into Go.

[0]: https://www.freebsd.org/cgi/man.cgi?query=style&apropos=0&se...

[1]: https://www.kernel.org/doc/Documentation/CodingStyle

I was curious about that too, so I did a little searching around to find out why. Apparently tabs are the officially recommended format and are emitted by the code formatting tool `go fmt`.

http://stackoverflow.com/questions/19094704/indentation-in-g...

Yep, gofmt defines and applies a standard formatting that uses tabs for indentation. Using tabs means that everyone can use their own preferred tab stop in their editor while operating on the same code.
gofmt enforces tabs.
Given that, I'm surprised to see that tabs are less prevalent in golang than two spaces are in ruby.
That would be disturbing - it would indicate that people are eschewing go fmt.
It could be more non-go files in the go repos throwing off the numbers?
Go users aren't satisfied with what's already being used? Big surprise.
Not sure I follow. Go fmt is a built-in linter (for lack of a better word) tool. It's not required, it's not unique to Go nor is not using a linter unique to Go users.

In general it tends to have much more religious support among users because of its ease of use and rigid, inarguable formatting.