4 ms·
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
by markbnj 11y 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.
- untog 11y agogofmt enforces tabs.
- benatkin 11y agoGiven that, I'm surprised to see that tabs are less prevalent in golang than two spaces are in ruby.
- nkozyra 11y agoThat would be disturbing - it would indicate that people are eschewing go fmt.
- Tobani 11y agoIt could be more non-go files in the go repos throwing off the numbers?
- iLoch 11y agoGo users aren't satisfied with what's already being used? Big surprise.
- nkozyra 11y agoNot 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.
- Tobani 11y agoIt could be more non-go files in the go repos throwing off the numbers?
- cespare 11y agoYep, 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.
- fbonetti 11y agoI 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-go-tabs-or-spaces http://stackoverflow.com/questions/19094704/indentation-in-g...
- nzp 11y agoIn 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&sektion=0&manpath=FreeBSD+10.2-RELEASE&arch=default&format=html https://www.freebsd.org/cgi/man.cgi?query=style&apropos=0&se... [1]: https://www.kernel.org/doc/Documentation/CodingStyle https://www.kernel.org/doc/Documentation/CodingStyle