Live data from Hacker News

Gofmt No Longer Allows Spaces. Tabs Only

code.google.com

51–57 of 57 posts

Re: Gofmt No Longer Allows Spaces. Tabs Only

#51
post #49
post #46

Earlier quoted context omitted.

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).

Oh, you're right. I should have tried it before commenting :)

Re: Gofmt No Longer Allows Spaces. Tabs Only

#52
post #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.

Yep. Asking a developer about style/formatting is an amazing filter if you have a lot of candidates... the answers I am looking for include "the language / platform standard", "the overwhelming most popular standard". The answers I have gotten have been nothing short of insane at times. I had a guy explain to me for almost 25 minutes why HIS system is UNIVERSALLY applicable to our code base, from C and C++ (multi platform) to Python to Makefiles...

Re: Gofmt No Longer Allows Spaces. Tabs Only

#53

I'm personally in the spaces camp but my favorite point in favor of tabs no one has mentioned is all of the bytes you're saving. In a large codebase you can save kilobytes to megabytes by switching from spaces to tabs. :)

Yes, I see the smiley, but I thought it would be fun to measure this effect anyway. I whipped up a small Python script to measure the potential savings, and ran it across the 450kLOC GlusterFS codebase. It reported 3.4MB of savings (both realized and potential because our code isn't as consistent as it could be). I'm generally in the spaces camp myself, and believe that 3.4MB just isn't worth worrying about any more (despite being worth ten of the floppies that were omnipresent even several years into my career), but it's still a surprisingly high number.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#54

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.

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?

> What issues have you seen with regards to using tabs?

How does a team adopt a standard regarding line length if their code base uses tabs and the team members specify different tab widths in their editors?

In my experience, devs that prefer tabs over spaces have a tendency to be unconcerned about line lengths, and their lines of code can become annoyingly long.

For example, the most popular Go project at GitHub[1] is Docker. Docker's code base contains Go files with lines of code that are hundreds of columns wide.[2] Gross. ;-)

[1] https://github.com/search?l=Go&q=stars%3A%3E0&type=Repositor...

[2] https://github.com/dotcloud/docker/blob/master/api/client/co...

Re: Gofmt No Longer Allows Spaces. Tabs Only

#55

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.

Spaces make zero sense for indentation. Why would you want to use them instead of tabs, which were invented for indentation and make perfectly logical sense (3 indents, 3 tabs and editors can dynamically adjust the width of your tabs). You get none of that logic with spaces.

Re: Gofmt No Longer Allows Spaces. Tabs Only

#56
post #23

Earlier quoted context omitted.

I'd say it's newsworthy to large Go shops that use spaces with gofmt and now have to change indentation in their repos. This isn't insignificant. Also it requires additional flags for things like blame/diff to ignore whitespace changes.

no such large go shops exist.

Oooh yes they do. GP and I both happen to work for one. :-)

Re: Gofmt No Longer Allows Spaces. Tabs Only

#57

I'm personally in the spaces camp but my favorite point in favor of tabs no one has mentioned is all of the bytes you're saving. In a large codebase you can save kilobytes to megabytes by switching from spaces to tabs. :)

Yes, I see the smiley, but I thought it would be fun to measure this effect anyway. I whipped up a small Python script to measure the potential savings, and ran it across the 450kLOC GlusterFS codebase. It reported 3.4MB of savings (both realized and potential because our code isn't as consistent as it could be). I'm generally in the spaces camp myself, and believe that 3.4MB just isn't worth worrying about any more…

Did you take into account filesystem block size?
Post reply on HN