
Tabs or Spaces? The Top Starred Repositories in GitHub Analysed - fyskij
http://ukupat.github.io/tabs-or-spaces/?
======
untog
I don't understand why this is still an issue in 2015. Why can't our source
control software take code indented any way, any how, and convert it to your
personal preference when you pull the repo? It's not like we enforce what
color syntax highlighting you use or what font.

Honestly, the hours that have been wasted debating tedium like this in
programming...

~~~
benatkin
The proper way to do that would be for everyone to use tabs for indentation.
The authors of golang seem to have taken this view.

~~~
iLoch
The problem with this is that if you have added tab indenting to line up with
a certain character in the line above, the length of the tab character would
affect where the text on the next line is actually placed, depending on
individual users' preferences. Spaces are uniform and standard length.

I believe this is the only real argument against tabs. I'd prefer to use tabs
because that's exactly what they were designed for, however this use case is
fairly prevalent in programming so it can't be ignored.

~~~
dilap
tabs to indent, spaces to align.

this is what go does, and it works great. take any gofmt-formatted style, set
your tab size to anything you like, and it will still look great.

it's baffling and slightly tragic that this style of indentation is not more
popular!

~~~
randomanybody
Mere humans are incapable of doing this right as most don't run with show
whitespace (so tabs and spaces _look_ different) & many don't grok the
difference between indentation and alignment.

I wonder if gofmt logic can be extended to other languages.

~~~
dilap
Well, in my opinion doing any sort of aligning-things by hand is pretty
tedious. I tend to just use indentation and not worry about alignment in
languages that don't have a formatter to do it for me.

E.g. I would write

    
    
        struct Foo {
            int bob;
            string alice;
        };
    

and not worry about lining up variables, whereas gofmt would give you

    
    
        type Foo struct {
            bob   int
            alice string
        }
    

which is fine too but not worth doing by hand IMO.

But if you are, it's not too hard to know where to use spaces and where to use
tabs, even w/o show whitespace. But it is true that this is more deeply more
than most programmers want to think about indentation. :)

------
benatkin
I wonder how many of those with tabs prefer their tab stops to be at something
other than multiples of eight spaces. If it's half of them that would be about
a sixth of the repositories.

GitHub has addressed them by supporting .editorconfig. Setting a tab size in
.editorconfig changes the tab size for viewing files but not diffs (last I
checked, a couple of months ago). If any GitHubber is reading, it would be
great for that preference to be used for diffs as well!

[http://editorconfig.org/](http://editorconfig.org/)

~~~
michaelmior
Huh. Never noticed that GH itself supported EditorConfig. Cool :)

------
SwellJoe
Anyone know why Ruby is 100% for 2 spaces? That seems impossible. Even Go
isn't _that_ consistent and it has gofmt which seemingly everyone uses.

~~~
gwintrob
The GitHub style guide agrees:
[https://github.com/styleguide/ruby](https://github.com/styleguide/ruby)

~~~
Macha
Here's the thing though, Python has PEP-8, which is _the_ style guide for
Python, and even that is only 91% 4-spaces. So that's pretty much the upper
limit on the impact of a style guide on a language's conventions, I would
imagine.

Go gets even higher, but only because there's an expectation of gofmt usage
which converts spaces to tabs.

------
pmiller2
I find it interesting that certain languages (F#, Ruby, Scala) are so
polarized against tabs. Some make sense, like Haskell, Go, or Python (and, to
an extent, CSS), but the rest kind of baffle me.

~~~
MichaelGG
Example:

    
    
      let x = let x = 1
              x + 1
    

If you use tabs the indentation is broken depending tab size. Some languages
prefer needless symbols to do this; I prefer the cleanliness of just
whitespace.

~~~
rascul
The indentation is fine, the alignment is broken. Tab to the indent level and
align after that with spaces.

~~~
MichaelGG
The actual indent level is wherever the second let begins. It's equivalent to:

    
    
      let x = 
          let x = 1
          x + 1
    

Seems inconsistent to have to use a mix of tabs and spaces in different
scenarios of visual preference.

------
nikolay
I prefer leading tabs and spaces for everything else. The fight over tab size
is irrelevant in the case where you align with spaces outside of indenting
with tabs.

------
forgotmypassw
Personally I prefer tabs for indentation and spaces for alignment. Also what's
wrong with these charts? They keep shrinking and expanding you can't tell
what's going on.

------
santaclaus
Three spaces fares horribly in this analysis. I wonder why the aversion for
three? Are odd numbers inherently less appealing?

~~~
yhager
It's not a power of two!

But really, I recently worked on a project where we used 3 spaces, and it's
works quite well. Not too little, not too much.

I can't remember why I've never considered it before..

~~~
lawpoop
I will try out three space on my next project.

Your ideas are intriguing to me and I wish to subscribe to your newsletter.

~~~
yhager
> Your ideas are intriguing to me and I wish to subscribe to your newsletter.

You must be confusing me with someone else

~~~
lawpoop
It's a humorous quote from the Simpsons.

------
stordoff
Looking at this just made me realise that IDLE (Python IDE) inserts four
spaces instead of tab when you indent using the tab key. I've always used tabs
(1 tab = 1 level of indentation) for my personal projects, and only just
realised why IDLE's "tabs" seem short by default.

~~~
Macha
Most IDEs I use have 1 tab = 4 spaces visually at least as their default
though. It's only old Unixy tools (e.g. Emacs) that default to 8 space tab
display.

------
markbnj
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
gofmt enforces tabs.

~~~
benatkin
Given that, I'm surprised to see that tabs are less prevalent in golang than
two spaces are in ruby.

~~~
nkozyra
That would be disturbing - it would indicate that people are eschewing go fmt.

~~~
iLoch
Go users aren't satisfied with what's already being used? Big surprise.

~~~
nkozyra
Not 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.

------
ChuckMcM
That is a fun analysis, I use 4 space tabs (where hard tabs are in the code,
and ts=4 in .vimrc). Hard tabs are essential on proportional font editing
systems, otherwise your code goes all over the screen!

------
smilekzs
The pie chart would be more readable if the "space count" is directly on the
pie slice (instead of tooltip/legend)

------
awqrre
Why use such a small selection of repositories? and why does Go seem to use
all tabs?

------
Gedrovits
I like the Ruby, it really have example "standard".

------
jehna1
Just a side note: why does a website still need to alter my browser's scroll
in 2015?

~~~
callumlocke
I don't think it does?

~~~
plorkyeran
Scrolling is really janky for me in FF, but afaict it's just due to the charts
being expensive to render rather than the site screwing with scrolling.

------
dendory
I really cringe when dealing with spaces, which is a real problem since I code
in Python a lot, which cannot deal with a mix of both. I don't understand
people using 2 or 4 spaces at every line, it's so much slower. Sure the first
time they probably use a tab and their editor is setup to replace with spaces,
but as soon as you go back to edit you need to deal with the multiple spaces.

I say tabs for all!

------
Jemaclus
Tabs for indentation, hands down. Every editor out there worth its salt can
adjust the tab size the way you want. If you want 1 tab = 2 spaces, you can do
that. If I want 1 tab = 4 spaces, I can do that. Either way, it's one tab, and
we're all happy. It's literally a win/win scenario. I have never understood
the argument for spaces for indentation, not when tabs are at our disposal.

~~~
webo
You just described spaces for indentation.

A tab is a special ascii character, which most IDE's replace with spaces if
you want to (like you described).

~~~
nerdwaller
I believe you are misunderstanding what they're saying. they are saying you
use the special characters and your editor can display it as you please (2char
wide or 4char wide). if you literally replace the tab char with N spaces, my
editor will now show it as N spaces.

