Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
[dupe] 400k GitHub Repositories: Spaces or Tabs? (medium.com/hoffa)
21 points by ironchief on Aug 31, 2016 | hide | past | favorite | 17 comments



Would be interesting to see a statistic on 2 spaces vs 4 spaces as well. Somehow, I can never get used to 2 spaces, the code feels too cluttered. This applies to json/html/xml as well.


I imagine a lot of the stats are based on tooling defaults. For Java we have a corporate standard to use tabs but most developers aren't even aware of their indents. Eclipse defaults to spaces so thats what ends up in a lot of code.


I've found that a lot of developers I talk to prefer tabs (for indenting only) but go with spaces when they start a new project because they feel like it's less contentious for some reason.


Am I seeing something totally incorrect?

It says:

py | files/tabs = 27,525 | files/spaces = 589,917

How is this possible?


I fail to see what is the problem, care to elaborate?


Spaces are strongly preferred in the official style guide: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces. I've been programming Python for 11 years now and have never seen a file with tab indentation.


But tabs let everyone see it how they want to. I've never understood the draw for spaces...


The problem with that logic is some people (like myself) think the style guide is wrong :P.


Interesting how Ruby has almost no code indented with tabs, while Go has almost no code indented with spaces (I believe this is due to gofmt, but I might be wrong).


Yep, it's due to gofmt, which enforces tabs for all semantic indentation and spaces for all alignment indentation (which means lines never start with a space).


"Hey guys, how can we make the whole tabs vs. spaces thing even worse?

"How about we promote mixing the two?"


Actually, I think that mixing the two (alignment is for spaces, indentation is for tabs) fixes all of the problems faced by both camps. It makes the tab width configurable, without ruining any visual alignment you've done.


That is what I use, tab for indentation (left-most chars of the line), space for alignment.

This what, regardless the editor, the indentation is always correct and the alignment all the same, the code simply slides left or right depending on the tab-size of the editor.



Hmm, but how many .vimrcs have

set shiftwidth=4 softtabstop=4 expandtab


well, yes, of course all the space users are using the <tab> key.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: