Developers Who Use Spaces Make More Money Than Those Who Use Tabs (stackoverflow.blog) 515
An anonymous reader writes: Do you use tabs or spaces for code indentation? This is a bit of a "holy war" among software developers; one that's been the subject of many debates and in-jokes. I use spaces, but I never thought it was particularly important. But today we're releasing the raw data behind the Stack Overflow 2017 Developer Survey, and some analysis suggests this choice matters more than I expected. There were 28,657 survey respondents who provided an answer to tabs versus spaces and who considered themselves a professional developer (as opposed to a student or former programmer). Within this group, 40.7% use tabs and 41.8% use spaces (with 17.5% using both). Of them, 12,426 also provided their salary. Analyzing the data leads us to an interesting conclusion. Coders who use spaces for indentation make more money than ones who use tabs, even if they have the same amount of experience. Indeed, the median developer who uses spaces had a salary of $59,140, while the median tabs developer had a salary of $43,750.
Pied Piper proves it too ... (Score:5, Funny)
Both? (Score:3)
"considered themselves a professional developer" ... "with 17.5% using both"
wtf? a professional developer uses both? really?
if and when i find a file that has mixed spaces / tabs, not only that, but 3 spaces instead of 4 then a tab for the fourth character. I slap that dev so fast the dev will try to rewrite git history.
Re: (Score:2)
Ever work with code that uses 4 spaces for column one, 1 tab for column two, 1 tab and 4 spaces for column three, etc.?
*shudder*
Re:Both? (Score:5, Insightful)
And that's why tabs should be the standard: people prefer different indents. Using tabs, everyone can have their way; set your tab width and all tabbed indents are automatically the width you want.
Now, for those who insist on tabs, let me explain why spaces are better: they allow you to align parameters and operators after the indent.
That's why my preference is to use tabs to indent, then spaces to align after the indent; best of both worlds. You're already using the tab key to indent and the spacebar to align, so there's no mental or physical overhead involved, the layout of your code is preserved and, if someone else prefers a different tab width, they can have it without breaking the alignment of arguments or operators (if you bother to make them look pretty) or altering how the code displays for you, or anyone else.
But, that's just a preference. When I'm working on someone else's code, I follow their conventions, because it really doesn't take any time at all to change an IDE setting (especially when my IDE can store per-project settings for things like tab width) and I'm not a dick.
Beyond that, if someone uses tabs on some lines and spaces on others within the same file... yes, slap them silly.
Re: (Score:2)
Who said it was within the same file?
For instance YML files specify that spaces must be used. But maybe tabs are standard on the project for other files.
But all of this is moot. In 2017, the correct answer to "tabs or spaces?" is "use fucking editorconfig and stop worrying about it".
Re: (Score:2)
Probably means tabs for indentation, spaces for alignment. They're still morons though.
Re: (Score:3)
Re:Both? (Score:4, Interesting)
The reason that most places don't have these check in hooks is simple - rule 1 in all good style guides is "if breaking the style guide in one off cases makes code substantially clearer, break the style guide."
Humans need to have the ability to say "no, in this one case it makes sense to do something odd to make this code readable".
Only dummies and newbs argue stupid shit (Score:5, Insightful)
Proof: neither side makes jack-shit as a coder
Re: (Score:3)
Re:Only dummies and newbs argue stupid shit (Score:5, Insightful)
Survey says (Score:5, Insightful)
If the median salary was under $50k, then I'm not sure who they were surveying, but it wasn't professional developers.
Re: (Score:2)
Re: (Score:2)
At least not in this country... In some places $50K is good money...
Re: (Score:2)
At least not in this country...
Median household income in the US is $57,616 in 2016.
https://en.wikipedia.org/wiki/Household_income_in_the_United_States [wikipedia.org]
Re: (Score:2)
CA median is over 60k$.
Si Valley median is over 90k$
In 2013, certainly higher now. That's median for everyone, competent techs should be north of that number.
Re: (Score:2)
That's median for everyone [...]
Median means that half make less and half make more. It doesn't mean everyone makes the median.
[...] competent techs should be north of that number.
Entry-level tech jobs in Silicon Valley starts off at minimum wage ($10 per hour/$20K per year).
Re: (Score:2)
Show me one job listing looking for techs in SI valley at $10/hour? Geek squad pays better and has no competent employees.
Re: (Score:2)
Show me one job listing looking for techs in SI valley at $10/hour?
Dell techs who have to drive 200+ miles per week. Those positions are typically available between $10 to $15 per hour. Prior to the last minimum wage increase or two, Dell paid $7.50 per hour.
One small company I interviewed for in 2014 tried to talk me down into accepting a position at $10 per hour. Since my name was similar to another employee, the recruiter accidentally sent me the salary spreadsheet. All the techs were making $10 per hour.
Geek squad pays better and has no competent employees.
They can't be making that much if they're also on the government p
Re: (Score:2)
Most developers live in neither place, you stupid ass-wipe.
Re:Survey says (Score:4, Informative)
If the median salary was under $50k, then I'm not sure who they were surveying, but it wasn't professional developers.
Those are global averages. Keep reading and you'll see the region specific charts and numbers. I think the averages for the US were around $100K and $80K.
Re:Survey says (Score:4, Insightful)
Yeah, my hunch is in a true survey of all programmers, it's the tab-users who make more money. Tabs are a relic from the old typewriter days, so older programmers are more likely to use them. And older programs tend to make more money.
It's the other way around. Old programmers worked on systems where the size of a tab was fixed at 8 spaces and could not be changed. Since 8-space indentation is way too much, they used either a mix of tabs and spaces to get the right indentation level, or spaces only. And then when we all started to get editors with configurable tab sizes, the mixed solution resulted in an unholy mess which was most easily fixed by standardizing on spaces only.
And old programmers tend to make more money, so money is correlated with spaces-only indentation.
Of course they earn more! (Score:5, Funny)
Those idiots take four times longer or more to indent their code compared to those of us who use tabs and get home earlier thus working less hours.
Re: Of course they earn more! (Score:2)
That's because they get paid by the character (Score:5, Funny)
Editor (Score:2)
I press tab but the editor inserts whatever the project requires. Did the question account for this?
Re: (Score:2)
Haha, yup. This. Don't sweat the small stuff.
Self explanatory really. (Score:2)
Did they take language into account? (Score:4, Interesting)
Re:Did they take language into account? (Score:5, Informative)
If only they had a graph that displayed how they checked for your easy explanation and controlled for it.
Oh wait, they did.
Have you ever heard of clicking on a link?
Reindent (Score:2)
I used to be religious about using a 2 space indent, but I no longer program in Python, so, now, who gives a flip?
Now I just want my code to look good. In Visual Studio, I do Ctrl-A, Ctrl-K, Ctrl-F, and I don't even know if it does tabs or spaces, and I don't care.
Also, I agree that those surveyed are incredibly underpaid.
How about comments? (Score:2)
Anybody dare try a study about in code comments and Salary levels?
My guess is you will see the same difference between Emacs and VI users...
Who are the people on the graph using both?!? (Score:2)
Re: (Score:2)
Re: (Score:2)
I work on several projects with hundreds of different contributors. I just use whatever is there (sometimes within the same file!). So count me as "both" - though I prefer 2 spaces in general. I have to admit using a lot of 4 spaces in Python since that's what the editors seem to default to and it looks nice.
Eclipse serializes with spaces or tabs (Score:5, Informative)
Modern IDEs format code automatically and use spaces or tabs based on your settings. In addition, the auto formatter automatically adds whitespace when you go into the next line. It is most likely not a real dependency between whitespace and salaries, but it has more to do with which environment they use.
Charming and fun, but not informative (Score:3, Insightful)
Let's say that using spaces was taught in the 70s, while tabs was taught in the 80s.
Now let's say we ask people for their style and their income. The older programmers that by now make more money will say they use spaces, while the younger programmers will say tabs. This would account for the differences.
In short, this survey isn't providing enough data to control for any factor, and the likelihood that tabs and spaces actually impact the earnings of any programmer is 0.
Also, any programmer that uses spaces is going to Hell (which runs Windows ME on the user machines)
Re: (Score:2)
At these Salaries? The explanation is that only newbies answered the poll.
The tab/space 'debate' has been going on so long that 'tabs produce smaller files' was once a valid argument.
How much money... (Score:2)
How much money do developers who let their damn IDE do the indenting for them make? :)
Re: (Score:2)
Good question. Not 100% sure I'd notice what some of the tools I use are doing wrt spaces vs. tabs. If a good formatting tool is available I will NOT manually format code. Don't care how unfortunate the result is; bang on the 'format source code' key and stop thinking about it. I don't think any one of webstorm, qtcreator, visual studio, vscode or netbeans are using tabs, but as I said; it's possible I might not notice if they did. The one thing I can affirm with metaphysical certitude is set ts=4;set
I write ... (Score:2)
Bad Statistics. (Score:2)
There is a lot of questions out there, that these numbers don't seem to show.
1. Which languages do they use primarily. Python for example while can handle tabs, your code needs to be consistent so using spacing is better. Normally you also set the IDE to replace tab with spaces. Other languages that don't care about white space may allow tabs and spaces to be mixed.
2. What type of projects are they working on. Larger projects with mutable developers need to keep their coding style more or less synchroniz
cause vs correlation. (Score:2, Insightful)
This is probably an excellent example of where cause and correlation are not the same thing.
Here is my suspicion, as an old programmer. The REASON why spaces are encourage over tables is for consistency of printing on a physical paper.
Which is unimportant or irrelevant if you are not. a) doing code reviews where you are passing out dead tree copies like may have been done 10 to 15 years ago OR b) submitting source code formatted on word docs as some part of documentation to a customer as government contrac
Re: (Score:2)
>Here is my suspicion, as an old programmer. The REASON why spaces are encourage over tables is for consistency of printing on a physical paper.
Not just. I tend to use tabs because hey, 5 spaces for one key press, and also because it aligns non-proportional fonts.
However, MS SQL is inconsistent in its rendering of tabs. If I copy code from a script window to a SQL Agent job, everything looks like garbage... so sometimes spaces win out.
I suspect a good part of the spaces vs. tabs debate ignores what env
OB Scene from "Silicon Valley" (Score:4, Informative)
https://www.youtube.com/watch?... [youtube.com]
Principles (Score:2)
Sure, if you sell your soul to the devil you can make a ton of money working for the Banksters or the Military Industrial Complex.
Am I late for the holy war?
Why not make it a default? (Score:2)
Re: (Score:2)
... Python interpreter complains about mixing tabs and spaces....
Really? I had heard a lot of good things about Python. But if it get confused when spaces and tabs are used interchangeable, that's pretty bad.
The real question... (Score:5, Funny)
One space or two after a period?
Sorry wrong crowd :P
(and don't you heathens dare say one)
Re: (Score:2)
The question is another example of why you should be using tabs.
Obviously one space is the right answer: the tool should provide the appropriate spacing without the user having to hit another key. If you need to hit space twice, then your tool is deficient.
Similarly, tabs allow better control of indentation without the need for either the user or the tool to insert multiple characters.
Re: (Score:2)
One space or two after a period?
Sorry wrong crowd :P
(and don't you heathens dare say one)
It is two when using a typewriter. :-)
Re:The real question... (Score:4, Informative)
It is two when using a typewriter. :-)
I learned to type with a typewriter, and back then most printers had a single fixed-width font, so it was still considered proper form to double-space after a period.
It wasn't until a couple years ago I learned that it wasn't considered proper form to double-space; decades of muscle memory are hard to unlearn.
Re: (Score:2, Funny)
Emacs untabify (Score:2)
Done. Where's my money?
Soooo... I should switch to spaces... (Score:2)
Re: (Score:2)
On Tabs and Spaces (Score:3)
It's tabs. Here's why:
1.) Tabs are characters specifically meant for indentation - that is the only reason this character exists.
2.) They use up way less bandwidth. I once cut down an HTML document from my space fanatic buddy from 80kb to 36kb just by converting from spaces to tabs. When 50+% of your bandwidth is used up by whitespace, you're a shit coder. True thing. ... Use spaces on my product and I'll woop your ass.
3.) With tabs everyone can decide on his own how far the indent is. That's how it's meant to be. That's the whole point of the indent character called "tab".
That said, I've given up on trying to explain the above to space junkies - they really don't seem to get it.
Today I usually avoid this discussion and settle for whatever the official standard is for a given programming language and use buildtools that clean up the code form excess whitespace before deployment on the web. For JavaScript that's space-indent with two spaces - really shitty, but I guess they're trying to suck it up to the C-snob crowd, so who am I to think I could stop them. The advantage in going with whatever is the standard for a given PL is that you can use the standard linters and commit hooks as they come and easyly set up your CI and build environment in such a way that it enforces uniformity. If that means only commiting two-space indents, I'll bite the bullet. Especially if I'm the lead and/or responsible for the dev-pipeline.
Re: (Score:3)
2.) They use up way less bandwidth. I once cut down an HTML document from my space fanatic buddy from 80kb to 36kb just by converting from spaces to tabs. When 50+% of your bandwidth is used up by whitespace, you're a shit coder.
The '90's just called and they want their webservers back. [wikipedia.org]
With a data point of one, it appears that people who use tabs might not understand the technology they're using. This may have explanatory power.
Re: (Score:2)
Re: (Score:2)
The problem is you don't know what everyone's indent has been set to. I work with files that have tabs that were clearly set to 2, 3, 4, and 8 spaces. I favor 2, but don't really care one whit. If the file uses tabs, I use tabs - if the file uses spaces, I use spaces. My editors all handle this just fine (sometimes with a manual tweak). However, if the file is already a mix of tabs and spaces, then I go with spaces. My OCD would like to change them, but that makes the diff tools show waaaaaay too many chang
Re: (Score:2)
[3 spaces]
I seem to recall that the C examples that came with MS QuickC used an indentation 3. It is the only time I have encountered that in C/C++ code.
Re: (Score:2)
THIS!
Personally, I don't care about tabs verses spaces, it doesn't make much of a difference to me.
Re: (Score:2)
Personally, I don't care about tabs verses spaces, it doesn't make much of a difference to me.
Unless you Python and get the two mixed up in the same file. That's why your text editor or IDE should have tab set to four spaces.
Re: (Score:3)
Still, it doesn't matter to me, only to the python parser....
BTW.. Any language that puts requirements on white space (like python) are bad ideas... That stuff when out of style a LONG time before even I started this software engineering thing 25+ years ago and there are good reasons for this.
Re: (Score:2)
Which always seems to be set before you got there.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
No, what it means is that the major tech companies that employ a lot of people, and pay a lot of money all have coding guidelines that say to use spaces.
I know for a fact the two very big ones use WebKit's style guide as a basis for most of their work, and that it asks you to use spaces.
Re: (Score:2)
The perfect number of spaces is 3.
Two is not enough to clearly see indents.
Four is just a waste of space.
Re: (Score:2)
No idea what I'm doing wrong, if it isn't the spaces!
If you grew up on typewriters, two spaces between sentences was the norm. A habit I had to break when I transitioned from typewriters to word processors years ago. The only time I see two spaces between sentences these days is in comments for Python code.
Re: (Score:2)
Word at least used to automatically convert end of sentence to two spaces anyway - maybe they've changed. I still use two spaces at the end of a sentence because it's easier to parse.
Re: (Score:2)
Word at least used to automatically convert end of sentence to two spaces anyway - maybe they've changed.
Unless you're using a monospaced font, all fonts provide a little extra space between sentences without adding an extra space character.
Re: (Score:3)
I'm pretty sure that the actual space (ASCII character 32) is rendered the same width regardless of its placement, even on proportional fonts. Individual characters stand alone in size and rendering, except when ligatures are involved. Some programs will insert a different kind of white space character - like an em or en space, or a second space after a period - but a font does not have anything different to offer when rendering a space between sentences. All you have to do is look at your own original c
Re:Yeah but (Score:5, Funny)
Most of the respondents wouldn't have understand the question because they actually use whatever their IDE does.
Space bar vs tab key (Score:2)
Most of the respondents wouldn't have understand the question because they actually use whatever their IDE does.
I read some of the comments expecting amusement, I was not disappointed. One specifically thought spaces-favoring developers were using the space bar rather than the tab key.
Re: Yeah but (Score:3)
Considering the average developer salaries were around $50k, they can't be that great. Who is even paying junior developers that little? I can't get a competent developer for under six figures even in the Midwest suburbs.
Re: (Score:2)
Re: (Score:2)
Yep, I'd be willing to take a bet on what the actual causation here is.
Large tech companies employ a lot of people, and pay a lot of money.
Most large tech companies use the WebKit style guide.
The WebKit style guide says to use spaces, not tabs.
Thus, most people who are getting paid big money are working at a shop that asks them to use spaces.
Re: (Score:2)
How about this (no clue if this is reasonable):
1) older programmers use spaces, younger use tabs.
2) older programmers have more seniority leading to higher salary (even if their job title doesn't change).
---> programmers that use spaces make more money.
I work at a company for which the above would be correct, but I'm not a programmer so I don't know if programming positions are similar (increases in pay with seniority while maintaining job title).
Re: (Score:2)
Close, but I doubt it has much to do with Webkit. Tabs work great for projects with one developer. Tabs generally seem to turn into a cluster fuck when there's any kind of diversity in the team. Large tech companies means large teams. Tabs mean war in big teams.
Alternate interpretation of the data (Score:5, Informative)
Re: (Score:2)
Damn, that's starting wages for someone right out of school! Maybe I should stop using tabs AND spaces.
Those are global averages. Keep reading and you'll see the region specific charts and numbers.
Re: (Score:2)
Re: (Score:3)
Yeah, this is heavily weighted towards S/SE Asia - and the fact that spaces versus tabs actually matters to them may say something.
Possible Explanation... (Score:4, Interesting)
Using spaces to indent is really kind of an OCD thing to do. There's the time and the counting and then redoing when you change something.
So maybe the real lesson is the OCD programmers make a bit more than non-OCD programmers.
Re: (Score:2)
Alternative explanation: People who use spaces have gotten so annoyed at how much a PITA formatting is, wrote an autoformatter, and have suddenly reclaimed all that time they would have otherwise spent formatting.
Re:Possible Explanation... (Score:5, Insightful)
The whole spaces vs tabs argument is so 90s, and seems more like arguing whether cow or bull leather whips are better.
Intelligent devs use IDEs that handle all this formatting nonsense for them, removing the entire argument in the first place and just get things done. If your preferred language doesn't have a modern IDE that handles this for you, perhaps that tells you all you need to know about your preferred language.
Re:Possible Explanation... (Score:5, Funny)
Intelligent devs use IDEs
Would that be vim or emacs?
Re:Possible Explanation... (Score:5, Insightful)
Re: (Score:3)
> arguing whether cow or bull leather whips are better.
Bull leather whips work better.
Most employers would agree.
Re: (Score:3, Insightful)
Using spaces to indent is really kind of an OCD thing to do. There's the time and the counting and then redoing when you change something.
So maybe the real lesson is the OCD programmers make a bit more than non-OCD programmers.
If you are using a decent text editor (eg. gvim and emacs to name two) indentation is actually done by the editor and is fully customizable, all you as the coder has to do is make sure that what you are coding has as few errors as possible. If you have to worry about indentation then you are not doing it right.
Re: (Score:3)
If you have to worry about indentation then you are not doing it right.
Or you care what your code looks like more than any automated algorithm ever could.
Though lately I've been making an effort to use tabs because I've been working on WRT stuff where every byte saved is worth something.
Re:Possible Explanation... (Score:5, Informative)
Using spaces to indent is really kind of an OCD thing to do. There's the time and the counting and then redoing when you change something.
Uhh .. no. Whether you use tabs or spaces is an editor config setting. At the human UI level it is barely even noticeable.
I use spaces at work so the code looks the same for everyone. For Python, I always use spaces since whitespace is part of the syntax. For other languages, I am not even sure. I would need to look at my .emacs file.
Re:Possible Explanation... (Score:5, Interesting)
I think you've hit the crux of it. Emacs, Visual Studio, and Eclipse (at least) all use tabs by default. What we may be seeing is a selection for people who know enough about their environment to configure it to work for them.
Re: (Score:3)
I use spaces at work so the code looks the same for everyone.
I use tabs so the code looks how everyone wants it to look. Like 4 spaces per indent? set ts=4. Like 8? Use set ts=8. etc.
For Python, I always use spaces since whitespace is part of the syntax.
For python I use a mix of spaces and tabs because I'm a shithead.
Re: (Score:3)
Using spaces to indent is really kind of an OCD thing to do. There's the time and the counting and then redoing when you change something.
If you think that there is a lot of counting, its because you have a ridiculous tab setting. It should be 2.
Re:Possible Explanation... (Score:5, Funny)
It should be 2.
It depends on the language. For bracketed languages like C++, Java, and Javascript, 2 spaces is correct. But for indented languages like Python, 4 is better to make the structure more clear.
What I really can't stand is people that use 8. That is never the right choice. My wife uses 8 spaces, and we have had plenty of arguments over that, especially when she edits my code, changes the indentation and then checks it back into the git repository with 100% of lines changed. But the final straw was when she started teaching the kids to use 8 spaces. We almost got divorced over that. I fought for 2, she fought for 8, so we compromised, and the kids are using 4 space indents, although neither of us is happy about that.
Re:Possible Explanation... (Score:5, Funny)
What I really can't stand is people that use 8. That is never the right choice. My wife uses 8 spaces, and we have had plenty of arguments over that, especially when she edits my code, changes the indentation and then checks it back into the git repository with 100% of lines changed. But the final straw was when she started teaching the kids to use 8 spaces. We almost got divorced over that. I fought for 2, she fought for 8, so we compromised, and the kids are using 4 space indents, although neither of us is happy about that.
This is why it is so important to get to know each other before getting married. My church recommends starting an open-source project together before even getting engaged, you learn so much about a person just settling on which license to use.
Re: (Score:3)
An excellent solution to your situation would be for your entire family to use no spaces.
You all get to spend time closer together as a result!
Re:Possible Explanation... (Score:5, Insightful)
Plopping something like this at the top of your file can help too:
# ex: set tabstop=4 expandtab smarttab softtabstop=4 shiftwidth=4:
# -*- Mode: tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- #
(if your editor doesn't know what to do with those, it's not worthy of use)
I delete that cruft when I encounter it. Editor settings belong in an editor, not in my code, thank you very much.