Live data from Hacker News

Gofmt No Longer Allows Spaces. Tabs Only

code.google.com

41–50 of 57 posts

Re: Gofmt No Longer Allows Spaces. Tabs Only

#41
post #14

Earlier quoted context omitted.

Grabbing some Clojure code because it's nearest to hand. Look here: https://github.com/clojure/clojure/blob/master/src/clj/cloju... I want the bindings being declared within that let to line up with one another. the first one immediately follows "(let [" so I need the rest to be indented six characters past where the let was originally indented. Six, not N times whatever the tab width happens to be in whichever edito…

The way people solve that is tabs for indentation and spaces for alignment. In my opinion this is a terrible compromise as mixing tabs and spaces is sacrilegious.

What's a compromise about it? Alignment and indentation are different semantic things, so it makes perfect sense to mix them.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#42

Who actually uses tabs instead of spaces? I'm genuinely curious--one of the first things pretty much any project I've ever been involved in has been the setting of tabs characters to become spaces, simply because all text editors are retarded in this regard. This is quite strange.

Go developers typically use tabs.

You should really try not to use the word "retarded" like this.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#43

I predict that this change will be reverted in a few months when the Go team realizes that code is read in a lot of different places, most of which never display hard tabs correctly.

Browser <pre supports tabs and defaults to the value of 8 (as is standard), so that shouldn't be a problem.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#44

Who actually uses tabs instead of spaces? I'm genuinely curious--one of the first things pretty much any project I've ever been involved in has been the setting of tabs characters to become spaces, simply because all text editors are retarded in this regard. This is quite strange.

Linux kernel uses tabs. I'm a fan of kernel-style, so I use it in my personal projects as well. It seems common in C projects, anyway.

https://www.kernel.org/doc/Documentation/CodingStyle

Re: Gofmt No Longer Allows Spaces. Tabs Only

#45

Who actually uses tabs instead of spaces? I'm genuinely curious--one of the first things pretty much any project I've ever been involved in has been the setting of tabs characters to become spaces, simply because all text editors are retarded in this regard. This is quite strange.

While I use 2 spaces in all my code because that's the winning convention in languages / frameworks I use, I've always felt tabs were a superior option, most notably because everyone can set tab width to what he likes, so you have a standard file with custom look and feel. I set my tab width to 2 chars ; if an other dev prefers to use 4 chars, there is no conflict.

The annoying part is that you can't set tab width in browser (afaik), which makes it painful reading code on, say, github, and being displayed an indent as the equivalent of 8 spaces. Browsers have to fix that.

So, to answer your question : I do not use tabs, but I would gladly do if offered the possibility.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#46

Earlier quoted context omitted.

The way people solve that is tabs for indentation and spaces for alignment. In my opinion this is a terrible compromise as mixing tabs and spaces is sacrilegious.

There is nothing wrong with mixing tabs and spaces. It works great.

Provided everyone use the same tab width :)

Re: Gofmt No Longer Allows Spaces. Tabs Only

#47
post #43

I predict that this change will be reverted in a few months when the Go team realizes that code is read in a lot of different places, most of which never display hard tabs correctly.

Browser <pre supports tabs and defaults to the value of 8 (as is standard), so that shouldn't be a problem.

You can also change it to 4 (which is what most editors use by default) via `tab-size`:

https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size

Re: Gofmt No Longer Allows Spaces. Tabs Only

#48

Earlier quoted context omitted.

Unsure if trolling or not. It's quite easy to have your editor represent a tab character as "n spaces" - where n is the number of spaces you find pleasing. In fact, I can't recall a serious editor where this isn't the case. What issues have you seen with regards to using tabs?

Often different editors on a project (hell, even between computers for the same user) may display the same file different ways, and you almost always end up with weird mixes of spaces/tabs when indenting things (especially if you're super picky like I can be and really, really care about things lining up). Simply having the editor expand tabs (to whatever people agreed on, usually 4 for C/C++ that I've seen) and save…

I hate that Zawinsky post. At the top, he says "I'm trying to avoid espousing my personal religion here, I just thought it would be good to try and explain the various sects." At the bottom, after thoroughly missing the point about semantic indentation, he says "So go forth and untabify!"

Re: Gofmt No Longer Allows Spaces. Tabs Only

#49
post #46

Earlier quoted context omitted.

There is nothing wrong with mixing tabs and spaces. It works great.

Provided everyone use the same tab width :)

Nope, works regardless of tabwidth; that's the point. Tabs for indent (these change size with tabwidth), spaces for alignment (these don't change so things stay aligned).

Re: Gofmt No Longer Allows Spaces. Tabs Only

#50
post #14

Earlier quoted context omitted.

Unsure if trolling or not. It's quite easy to have your editor represent a tab character as "n spaces" - where n is the number of spaces you find pleasing. In fact, I can't recall a serious editor where this isn't the case. What issues have you seen with regards to using tabs?

Grabbing some Clojure code because it's nearest to hand. Look here: https://github.com/clojure/clojure/blob/master/src/clj/cloju... I want the bindings being declared within that let to line up with one another. the first one immediately follows "(let [" so I need the rest to be indented six characters past where the let was originally indented. Six, not N times whatever the tab width happens to be in whichever edito…

> I want

Which is actually the problem gofmt solves.

The desire to express your individual preference through the way code is formatted is an issue not a feature.

The code may be read, maintained and handled by many other individuals during the life of the code, and gofmt is an attempt to provide an incredibly high degree of consistency in the way that the code is formatted to improve those things.

The Go way is simplicity, readability, maintainability.

Once you accept that consistency in formatting is important and a good thing to strive for, the only question is spaces vs tabs. But spaces is a highly opinionated option as the number of spaces used for indentation has to be uniform, whereas tabs allows for each individual to configure their editing tool to permit a degree of individual preference that does not sacrifice any of the consistency.

Tabs have the advantage, please configure your editor to suit your preference and not the code.

Post reply on HN