400,000 GitHub Repositories, 1 Billion Files, 14TB of Code: Spaces or Tabs? (medium.com)
Here's a debate that refuses to die: given a choice, would you rather use spaces or tabs? An episode of Silicon Valley last season had a bit on this. Now we have more data to analyze people's behavior. A Google developer has looked into 400,000 GitHub repositories -- 1 billion files, 14 terabytes to find that programmers with interest in specific languages do seem to prefer either tabs or spaces. Spoiler alert: space wins, like all the time.
Yeah, OK, I get it. Spaces make it easier to cut and paste your code into whatever and have it look the same. But does anybody seriously type all those spaces? You don't just set the Tab key to expand to spaces?
Breakfast served all day!
... except for the times I use spaces.
You may "use" tabs, but plenty of editors are set to translate the tab into N spaces.
Worse, plenty of editors import text documents and **change** the tabs to N spaces whether you wanted to or not.
Usually this results in a totally garbled python script.
https://app.box.com/WitthoftResume Code: https://github.com/cellocgw
The article conveniently ignores Python, a 100% tabbed language.
Paid Q&A/Research
Popularity is a poor measure of quality. Otherwise McDonald's would be Michelin starred.
Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
The whole point of a tabstop is you can change its width so a file can be indented to the preference of the person reading/editing it (set ts=[width] in vi). With spaces you're stuck with the (often poor) indentation the author chose who is essentially saying "Fuck you, you're going to read the code indented the way I want, not the way you want"
In theory, tabs are the right solution. In practice, spaces are the right solution.
-Chris
I think there'd be less of a debate if tabs were 4 chars in width, out of the box. Not sure they'd even bother with a tabstop setting had that been the case. Granted, you're always gonna have your freaks, like this one guy I worked for who insisted on 3 spaces for indentation, but they would have gotten nowhere had the default tabstop been reasonable from the start.
That being said, spaces for work code, tabs for personal code.
All this proves is that we Tabbers are being universally and systematically supressed by the Spacers (except in the Go community).
That's because when the Spacers kick the Tabbers out of the building they shout "Just go!", and the Tabbers think that's a language recommendation.
Ew. That's an unusual combination of tabs and spaces.
...and also because of Emacs.
If you use proportional fonts for programming, you deserve every bad thing that happens to you.
That is truly the worst of both worlds. If you're going to use tabs, then tabs should be used for indenting (i.e. the block-level of the code) and spaces for formatting after the appropriate indent has been achieved, and the two should not mix.
Doing it your way will improperly display in any other editor or viewer, including Emacs, that has a different-width tab -- which is pretty much all of them, since the 4-space tab-width is so popular.
And by this, I mean spaces are inferior, just like Betamax actually was.
Tabs are, of course, more logical because it lets the person viewing/editing the code decide how it looks. You can set your tab width to 2 chars for super tight code, 3 for a bit more obvious indentation, or a more standard look with 4. You can even go nuts and go with 8 spaces.
A tab semantically means "indent this one level". Two tabs = 2 indentations, etc... What the _fuck_ does 8 spaces mean? Is that one indentation or two? Oh, that's right, you have to look at the rest of the existing code to figure it out.
It's god damn ridiculous and to hell with the Spacers.
The argument was never about what button you push on your keyboard, it has always been about how fucked up your shit gets when someone else opens it in a different editor.
If I have been able to see further than others, it is because I bought a pair of binoculars.
https://www.emacswiki.org/emac...
(snigger)
This was an analysis of files on github, yes? And by definition, those files are managed by git, yes?
And thus, the files were created by all the young punks that rushed to git, because reasons, yes?
In light of those conditions, yeah. I can see why there's a prevalence of spaces. The analysis only considers the work output of (mostly) young idiots.I'll bet there's a prevalence on github of non-plumb braces, too.
People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
You have to use tabs, sure, but how on earth are they going to know what width you set them to?
SJW n. One who posts facts.
The type system is absolutly fine.
It's tiny and incredibly primitive.
If you think you need generics, you're doing it wrong.
I don't think I need generics, I know they make my life easier and so I want them. I've programmed for years both with and without them.
The funny thing of course is that go has certain generic structures, such as arrays, and maps clearly indicating that generic structures are worthwhile. It's jsut you can't define your own so if your problem domain doesn't map well on to the built in generics, it's a much worse language than if your problem does.
SJW n. One who posts facts.
But that's what I like about tabs. They can be set to display as however many columns each individual wants, rather than requiring everyone to agree on the same number. 4? 3? 8? Pi?
The regex used for determine tab vs. space is r'[ \t]', which matches the first space or tab in a line, not whether or not the first character in a line is a space or tab. Thus, for example, a using statement in C# (using System;) would count towards the spaces total where it shouldn't count towards either (unless preceded by spaces or tabs for some reason).
Fix the regex (r'^[ \t]') and rerun it, i doubt it will allow tabs to win (tabs rule spaces drool), but it would give more accurate results for the charts.
1. .json files shouldn't be counted because they're frequently generated by tools rather than by humans (or even human tools...)
2. Making an argumentum ad populum (i.e. an argument for or against spaces) is really just embarrassing yourself.
3. Arguing that everyone should use spaces for indentation just because that's how the rest of the project is formatted is nothing more than an appeal to tradition-- furthermore we have tools these days which can automatically transform the whole project to use tabs so it's not like it would amount to re-writing every single file by hand to make the change.
4. About the flame war... Here's a blog post that sums it up nicely. Spaces for indentation are objectively inferior, provide no improvement over tabs, and are more difficult to work with. If your reason for using them is just to force everyone else to do things (i.e. read and write code) your way then screw you: you're literally one of the reasons the world sucks.
on many of the old video terminals you could set arbitrary points for the tab stops. tab would jump your cursor to the next tab column on the current line.
There is usually a command to set a tab at the current column, clear at tab at the current column and to clear all tabs. (VT100 and maybe VT52, probably no tab support in something ancient like ADM-3A)
so you could setup 2 space for the first tab, 4 spaces for the next four, 8 spaces for the remaining. ...
a the most elegant tab stop setup would be: 1, 1, 2, 3, 5, 8, 13, 21, 34,
“Common sense is not so common.” — Voltaire