6 ms·
OT but I think GitHub should show tabs as 4 columns. I find Go code is hard to read with all this whitespace.
by Kiro 12y ago
OT but I think GitHub should show tabs as 4 columns. I find Go code is hard to read with all this whitespace.
- tuxone 12y agoOr better, we should save source code files replacing tabs with spaces. That's the best practice that makes everybody happy.
- custardcream 12y agoGo uses tabs. That's the law. It's in the documentation. Groups of spaces and tabs are semantically different. Tabs mean indentation. Spaces mean spaces.
- tuxone 12y agoMy apologies, thank you for the clarification.
- treehau5 12y ago>Tabs mean indentation. Sorry but this is false. The only thing a tab means, is tab. Please provide your reasoning for the down voting. Thank you.
- custardcream 12y agoThe dictionary in front of me disagrees: "A key on a computer keyboard that, when pressed, inserts a special ASCII character used for formatting text, as in indenting a line or block of text." Actually going back it means tabulation which was an early form of alignment of tables on typewriters. The tab key advanced the carriage to the next tabulation point. It was repurposed as a way of indenting code later and it has become an additional definition of that fact. (I'm old enough to have owned a typewriter, a nice Selectric one as well ;-)
- treehau5 12y agoWe are talking about computer semantics which exist in a discretized world, not english language semantics. By your logic, the word integer would be any number not a fraction or decimal down to negative infinity up unto positive infinity. There is no concept of infinity on a computer. Anyways, that's besides the point, and I think you missed the meaning behind my comment. The reason why a tab space cannot semantically mean indentation in our world, is because nobody can agree on what that indentation should be. Since you are old enough to have owned a typewriter, maybe you are old enough to remember that by legacy, a tab was equivalent to exactly 8 spaces, and much of our software that runs the internet makes that assumption. Now however, people are saying "use tab to mean indent and everyone can have their way" To quote mikko, "There is no style guide or coding conventions saying that the tab character should be the indent. This assumption is easy to make because it allows you to stick your head into the sand, ignore the surrounding world and by singing “let the users pick their own tab width” mantra." Again, this wasn't to start a tab vs spaces war for go, and why go chose tabs. It's fine to make a choice, but it was your second statement that provoked my comment.
- custardcream 12y agoI get what you mean but a tab is purposely meaningless and unqualified. It means 1 indent, not 8 spaces, 3 bananas or one tree. It is a unit. How the user displays that is up to them.
- trebor 12y agoThis. Absolutely this. I used to hate tabs and want 2 spaces only, until I started working with other developers. Then suddenly tabs made sense, especially when you've got IDEs coercing every edited file to a person's indentation standard. Standardize on the tab and the pain goes away.
- munificent 12y ago> There is no concept of infinity on a computer. Sure there is: http://en.wikipedia.org/wiki/IEEE_754-1985#Positive_and_negative_infinity http://en.wikipedia.org/wiki/IEEE_754-1985#Positive_and_nega...
- Artemis2 12y agoSpaces are tolerated, but the usage of tabs is very encouraged.
- deleted 12y ago[deleted]
- halostatue 12y agoThe Go team has made the decision that the language supports tabs for indentation, and it’s enforced by `go fmt`.
- andrewprock 12y agoWhile this is clearly the wrong decision, one has to applaud the Go team for building `go fmt` and thus putting and end to unproductive discussions about formatting. (Although it would have been nice if `go fmt` didn't change code semantics.)
- couchand 12y agoI'm relatively new to Go, and like you I wholeheartedly agree with the idea of solving formatting once and being done with it (and as an aside, I agree that tabs are the wrong decision). It was my impression that gofmt was essentially a pretty printer. Can you point to examples where it changes semantics?
- andrewprock 12y agogo fmt will reorder your imports, which means that if there is an import ordering dependency, it will either be exposed (or hidden) by go fmt.
- ominous_prime 12y agoyou should never have an import order dependency, since initialization order is unspecified.
- andrewprock 12y agoShoulda woulda coulda: https://bugs.launchpad.net/gocheck/+bug/1178806 https://bugs.launchpad.net/gocheck/+bug/1178806
- 12y ago
- _ak 12y agoWhy? n spaces encode a specific preference for indentation, while tabs just represent a level of indentation. How many columns these actually are is entirely up to personal preference and editor configuration. That's why tabs are always superior for indentation.
- andrewprock 12y agoIt's actually quite a bit more subtle than that. Even `go fmt` uses tabs to format indentation, but uses spaces to format alignment. This is distinct from mechanical typewriters which used variably sized tab-stops to handle tab alignment.
- boomlinde 12y agoNo, it should show it as tabs, because that's what it is. Ideally, it should show it as 8 column tabs, as that is what gofmt assumes by default.
- Kiro 12y agoSorry, changed "spaces" to "columns".
- boomlinde 12y ago... and the only reason for it to be four columns is that you personally find it hard to read, or do you have another, more compelling argument against using 8 column tabs?
- possibilistic 12y agoPersonally, I find 8 columns to be an incredible waste of horizontal space. I frequently place editor windows/panes side by side, and using 8 columns or spaces wastes valuable screen real estate. But this isn't just a reaction rooted in practicality. To me, this looks and feels absurd. It kind of hurts to read. Again, this is just my personal take. I prefer scope indentation of any kind to render as 4 spaces, but I'm okay with 2 as well.
- Dewie 12y agoI agree. For me, I want enough indentation to make the structure obvious. 8 columns is way overkill in that regard.
- Kiro 12y ago> and the only reason for it to be four columns is that you personally find it hard to read Yes, it was just a personal opinion.
- boomlinde 12y ago
- vog 12y agoActually, you can configure GitHub to do that. Just add ?ts=TABSIZE to the url. For example: https://github.com/facebookgo/httpcontrol/blob/e815eb2/httpcontrol.go?ts=2 https://github.com/facebookgo/httpcontrol/blob/e815eb2/httpc... (tab size 2) https://github.com/facebookgo/httpcontrol/blob/e815eb2/httpcontrol.go?ts=4 https://github.com/facebookgo/httpcontrol/blob/e815eb2/httpc... (tab size 4) https://github.com/facebookgo/httpcontrol/blob/e815eb2/httpcontrol.go?ts=12 https://github.com/facebookgo/httpcontrol/blob/e815eb2/httpc... (tab size 12, seems to be the maximum) Unfortunately, there seems to be no such entry in the account settings. I'd love to set this value once and for all, or maybe once per file suffix (2 spaces for stuff.xml, 4 spaces for stuff.go).
- shurcooL 12y agoI, too, would like to see an entry to set my preference for my account. I prefer tabs of size 4. In fact, this is the only remaining issue I have left at https://shurcool-legacy.github.io/bettertogether/ https://shurcool-legacy.github.io/bettertogether/.