4 ms·
400k GitHub Repositories: Spaces or Tabs?
- dashoffset 10y agoInteresting 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).
- phasmantistes 10y agoYep, 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).
- Chaoshade 10y ago"Hey guys, how can we make the whole tabs vs. spaces thing even worse? "How about we promote mixing the two?"
- cyphar 10y agoActually, 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.
- delcaran 10y agoThat 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.
- gramakri 10y agoWould 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.
- greenyoda 10y agoPrevious discussion: https://news.ycombinator.com/item?id=12397246 https://news.ycombinator.com/item?id=12397246
- Daviey 10y agoRepost https://news.ycombinator.com/item?id=12397246 https://news.ycombinator.com/item?id=12397246
- gkanapathy 10y agoHmm, but how many .vimrcs have set shiftwidth=4 softtabstop=4 expandtab
- AjithAntony 10y agowell, yes, of course all the space users are using the <tab> key.
- teacurran 10y agoI 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.
- catskul2 10y agoI'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.
- phantom_oracle 10y agoAm I seeing something totally incorrect? It says: py | files/tabs = 27,525 | files/spaces = 589,917 How is this possible?
- LoneWolf 10y agoI fail to see what is the problem, care to elaborate?
- perrygeo 10y agoSpaces are strongly preferred in the official style guide: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces 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.