Live data from Hacker News

Gofmt No Longer Allows Spaces. Tabs Only

code.google.com

31–40 of 57 posts

Re: Gofmt No Longer Allows Spaces. Tabs Only

#31

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.

My project, Pokémon Showdown (https://github.com/Zarel/Pokemon-Showdown) uses tabs, although it's not for any religious reasons, it's just what I was used to when I created the project. I suggested changing to spaces when I learned they were more popular, but my most opinionated coder preferred tabs so I kept it at tabs.

Tabs and spaces both have their respective advantages and disadvantages.

Advantages of tabs:

- you can choose your indentation width in most editors, so coders don't have to agree on indentation width (this is really the only major advantage)

- most very-basic editors that can't be configured, such as Notepad or the command-line directly, will default to having the tab key insert a tab character, which is easier to press than space N times (it's rare to edit code in such cases, though)

- slightly smaller file-size, although this is pretty irrelevant in modern times

Advantages of spaces:

- certain editors are dumb and will mangle tabs in various ways (for instance, converting "3 tabs for indentation, 9 spaces for alignment" into 5 tabs and 1 space)

- most file viewers that won't let you configure tab width (for instance, browsers, which is relevant to viewing code on GitHub) will have tab width set to 8 spaces, which is very awkward

- avoids the problem of some people accidentally using tab for alignment and then having alignment be messed up when coders have different tab width settings

- certain text fields, such as browser text boxes, will have the tab key focus the next input field instead of inserting a tab character, which makes inserting tab characters difficult sometimes (it's rare to edit code in such cases, though)

Re: Gofmt No Longer Allows Spaces. Tabs Only

#32
post #6

Earlier quoted context omitted.

I got into beekeeping recently, and it's like this, except applied to everything.

Can you give some examples? I'm really curious.

Easily. Just get any two beekeepers to talk to each other and you'll find plenty of examples. Some common ones:

- Whether to use a [queen excluder](http://en.wikipedia.org/wiki/Queen_excluder) or not.

- What [kind of hive](http://www.beethinking.com/pages/what-is-the-best-bee-hive) to use, even.

- If using a Langstroth hive, whether to use [10-frame or 8-frame boxes](http://www.beesource.com/forums/showthread.php?291373-10-fra...).

- How/when/whether to [feed your bees](http://www.bushfarms.com/beesfeeding.htm).

However, despite having all these disagreements, it's an incredibly friendly community. It's expected that anyone you meet will do things differently from you, so people swap advice and adopt things that work with their style.

Edit: whelp, markdown doesn't work here but I'm too lazy to change it.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#33
post #31

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.

My project, Pokémon Showdown ( https://github.com/Zarel/Pokemon-Showdown ) uses tabs, although it's not for any religious reasons, it's just what I was used to when I created the project. I suggested changing to spaces when I learned they were more popular, but my most opinionated coder preferred tabs so I kept it at tabs. Tabs and spaces both have their respective advantages and disadvantages. Advantages of tabs: -…

You can style tab width in CSS though. If you want GitHub to have smaller tabs add tab-size: 2; to an appropriate selection in your site-specific CSS. I’m sure there are extensions that will do this for you. More info: https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size

Re: Gofmt No Longer Allows Spaces. Tabs Only

#34

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.

Tabs for scope, spaces for alignment.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#35
Awesome. The only thing that really matters is to have a convention, and tabs has been the accepted convention in the Go community since forever.

Changing go fmt to enforce the convention is simply making sure that people write code the same and frees the developers from the tireless discussion about which one is better. That alone outweigh any disadvantage of choosing one or the other.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#36
I prefer tabs (tab-size: 4), but I prefer even more if everyone follows the same conventions.

Dart, for example, uses 2 spaces. When I write Dart code, I use 2 spaces.

And that's the end of that. As history has shown, there is absolutely no point in discussing this. There is no clear winner.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#38

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.

>I'm genuinely curious

I find that very hard to believe. It is a holy war that has been raging for longer than many posters here have been alive. Are you also totally unaware that some people use emacs rather than vi? Do you consider it "retarded" that most systems launch vi when you type "vi"?

Re: Gofmt No Longer Allows Spaces. Tabs Only

#39
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 the bindings being declared within that let to line up with one another

Why? And is it really worth the noisy diffs you inflict on the world as a result?

Re: Gofmt No Longer Allows Spaces. Tabs Only

#40
post #20
post #16

The right way to solve all this tabs/spaces indentation mess would be to use Elastic Tabstops¹. 1) http://nickgravgaard.com/elastictabstops/

gofmt already uses elastic tabstops.

To quote [1]:

Not really. Elastic tabstops is about enabling variable width fonts to be used in text (and especially programming) while still lining up tabular columns. What gofmt does is to use spaces to align columns; a method described in http://nickgravgaard.com/elastictabstops/ as a "kludge".

1) https://groups.google.com/d/msg/golang-nuts/93t0LWvHrKM/y6oI...

Post reply on HN