689 comments

[ 2.2 ms ] story [ 304 ms ] thread
correlation != causation
Of course you'd say that, you tab user!
Spoken like a space-using degenerate.

(J.k.: spaces FTW)

Which is exactly what the article says.
(comment deleted)
> The model estimated that using spaces instead of tabs leads to a 8.6% higher salary (confidence interval (6%, 10.4%), p-value < 10^-10). (By predicting the logarithm of the salary, we were able to estimate the % change each factor contributed to a salary rather than the dollar amount). Put another way, using spaces instead of tabs was worth as much as an extra 2.4 years of experience.

Maybe I'm not up on my statistics lingo, but saying "using spaces instead of tabs leads to a higher salary" sounds much more causal than "using spaces instead of tabs is correlated with a higher salary."

If they're going to say something leads to something else, I don't see how that one's justified over the reverse: "having a higher salary leads to using spaces." Isn't that's just as valid a conclusion from the data?

Yes, the word "leads" was an unfortunate choice.
The interesting question is teasing out why the correlation occurs at all.
Maybe so, but does correlation !== causation?
Which doesn't matter.

Correlation still:

(a) implies causation (it's a necessary attribute of causation, just not a sufficient one).

(b) makes it statistically more probable for someone to be making more money than another, if they use spaces and the other doesn't

I needed a good laugh this morning. But of course this is pretty bogus relationship. People who drive Teslas make more money than those who drive Gremlins.
You get paid by the keypress?!
Who is manually entering spaces rather than instructing your editor to do it for you?
... but what is pressing the space bar if not instructing the editor to insert a space for you?
But there's an actual causation here (you need more money to buy a Tesla). Use of tabs and salary don't seem to have any relation one way or an other.

My personal guess would be that using spaces is a practical decision and might be more popular towards older, more experienced devs (who are therefore better paid).

On paper tabs sounds better, they're "configurable", you should indent with tabs and align with spaces, yada yada and everything is good in the world.

In practice however it becomes a big mess real quick unless you only work on projects with very good and perfectionist developers who understand when they should indent and when they should align and how they should configure their editors to do the right thing. See for instance the linux kernel codebase, it looks like arse if you don't use 8-space tabs and the coding style even tells you to use that value (it shouldn't really matter if tabs were used "right", except maybe for 80-column limits). So why even bother with tabs in this situation? Do we really care that much about wasting a few bytes?

Therefore I gave up on tabs a long time ago and tell everybody to just use spaces in all the projects I maintain.

Personally, I have bad experience with tabs. Experience and salary are correlated.

Also some languages are "tab friendly" and there are correlations between language and salary; see previous HN posts on the topic.

I'm thinking this has more to do with it.
(comment deleted)
See OP where blog author specifically disproves the language hypothesis.
There could be a third factor of conscientiousness that causes both high salary and use of spaces (to align your code just right). At least I will be using that excuse now when I spend time aligning function parameters in table columns.
(comment deleted)
> My personal guess would be that using spaces is a practical decision and might be more popular towards older, more experienced devs (who are therefore better paid).

They explicitly rejected this explanation after controlling for years of experience.

Oh, you're right. My mistake.

That being said I'd be curious to see "years of experience working in a team", because that's really when using tabs starts becoming tricky. If you're well disciplined and are the only person messing with your codebase the issues I mentioned in my previous post don't really apply.

I suspect that correlates pretty well with years of experience.
age != years of experience
They must be paid by the hour and all that spacebar pressing adds up
Probably devs who use spaces wear out the space bar more often, and demand high salaries to replace worn-out keyboards.
I thought the same before reading the article. But they actually tried to control for other variables (experience, country, language).

If you know another variable that explains the difference please let us know.

Stackoverflow usage. Highly paid tabistas don't need it.
How is the analogy relevant? What you wrote is self-evident (Teslas being more expensive). The other (spaces correlated with more pay) is not.
I use spaces.

Who do I contact for my check?

Submit an expense report to your employer and you'll be reimbursed for the extra bytes.
Jetbrains product users make more money? ;^)
How else do you think they can afford to pay for the licenses?
The full toolbox is less than a dollar a day - it's not like we're talking about really expensive licensing. They're not RedGate.
fun fact RedGate's website sends "GNU Terry Pratchett"
The $89 a year is not exactly breaking the bank.
The time savings alone probably paid for itself in two days of use.
(comment deleted)
Well that settles that! We finally have proof that spaces are superior to tabs... ;)
It's only proof that using spaces is selling out...
oh poor Richard ... (ceo of pied piper)
>Developers who use spaces make more money than those who use tabs

Sure, but how many spaces? grabs popcorn

Where does using vim to insert four Spaces everytime I press tab leave me?
A brilliant automation solution!
That's spaces. Or at least that's what I answered when I took this survey and I do the same thing in vim and all other IDEs.
Yea, I'm honestly surprised this is a thing still. I've not thought about the tab vs spaces "war" in years; because of Vim. I just hit Tab and whatever the pre-defined standard is, be it tabs or spaces and space count, is used.

Visually I can have it display in my editor of choice (Kakoune at the moment) however I want.

I guess I'm just saying, I would have thought the most common answer to this question would be: Whatever my employer / language standards dictate.

Employer and language has a lot to do with how much you make.

Imagine that half of those interviewed worked at Google.

i'm surprised people manually insert tabs/spaces. vim automatically indents for me and even if it didn't, formatting the code is one keybind away...
More spaces = more money

Awyis I'll be rich in no time!

Anything less than 16 is literally blasphemy, in the modern world everyone is using 4k 32:9 monitors and for the best level of readability heavy indentation may as well be mandatory.
This by itself disproves the Just World hypothesis.
Of course professionals get paid more, but I'm surprised there are so many tab users out there! Time to add a new interview question.
Nothing makes those going for spaces more "professionals".

Just oldsters cargo culting old kludges into the 21st century.

I believe the correct answer to that interview question would be "Follow the code style as established by the company, or keep it consistent within existing projects."
Agreed. People who follow the style guide probably earn more than either spaces or tabs.
Of course they do because they are pig headed ignoramuses who are insist on getting their way in spite of all evidence that they're wrong. So of course they are good at getting raises. ;)
Is this about whether you set your editor to convert tabs to spaces? (which is obviously tidier due to inconsistent treatment of tabs)

Or do some people actually use the space bar to indent code? (which is obviously insane)

Definitely the former. Anyone who indents there code by slapping the space bar repeatedly is a monster and should have their hands cut off.
Then this survey is surely measuring awareness of how editors work. Most code editors substitute spaces by default.
Well, of course. Only companies with fuck-you money can afford the extra bytes spaces take up versus tabs, so it follows logically that they'd pay their developers more.
yeah, just because in 2017 storing source code is the most expensive thing for a company. but really, the storage is almost free nowadays...
Seems unfair to downvote you just for misunderstanding, that was sarcasm friend.
It's pretty much an unwritten rule that a sarcastic joke on the internet with sufficient exposure will get a response by someone who didn't get it. Using /s really kills the fun (and whole point) of using sarcasm so it's a trade off to accept these comments will happen.

I'm impartial to downvoting as to reply literally doesn't usually add to the conversation, which is generally the point of downvoting. Losing karma shouldn't hurt your feelings.

I will don't understand why it's called Poe's Law if he said it in 2005. This phenomenon was well documented on Usenet by the early nineties.
Poe's Law is when extreme views seem to self-parody. That's different from someone missing the joke on mundane sarcasm.
Do you mean partial to? As in, you favor downvoting over commenting to point out their mistake? Don't mean to be nitpicky, just genuinely confused if that was a mistake or I'm misunderstanding.
I meant that as I'm indifferent to whether or not they get downvoted but I see there could be a justification for doing so.
Could also be that the reply is also an attempt to play the into the joke (kind of like a vaudeville straight man).
Yeah, I guess. If the person didn't catch the sarcasm they probably won't catch why they are being downvoted, at least 1 person has to tell them.
Yeah but we are human. Most people's feeling probably are hurt when their [non-malicious] comments are downvoted. But besides that I mostly agree with what you wrote.
I strongly think \s should be enforced in every post in HN.\s
Killed the fun with the second one.
I can't debate sarcasm.
For portability you should use /s, not \s. \s only works on Windows.
You should have escaped the tag, like this \\s. Your second tag closed, forcing people to take your post seriously.
(comment deleted)
I'm confused. Do you mean that we're allowed to create posts on Hacker News that are not sarcastic? I thought there was a rule, with a powerful AI enforcing it, stating that all posts had to be sarcastic. (Warning, this post is sarcastic and not meant to be taken literally.)
I've grown so tired of sarcasm. Online and in real life people are often saying the exact opposite of what they mean. We have to pick up the sarcasam to truly understand.
sarcasm is one of the true idiosyncrasies of humanity that differentiates us from the machines. Embrace it.
Right up until we can type "include('sarcasm')" and have it work.
The real issue with sarcasm is that it actually places the burden of subtleness on the speaker, whereas people will usually blame the listener for not understanding. If the tone and wording isn't just about perfect, then it's obviously easy to miss sarcasm, let alone the humorous intent. And that is sometimes very hard in writing, hence the "/s" which ruins the fun for everybody. Likewise if the listener isn't educated about the object of sarcasm, little can s/he get the irony of the statement... I think missed sarcasm has more to do with failed cultural fit than fault of anyone involved. Which is probably why it's much more common and accepted within social circles than in general discussion. HN clearly fits the former, though; sarcasm is just about yet another norm here!
> HN clearly fits the former, though; sarcasm is just about yet another norm here!

Agreed, this is why I didn't want to take a hard position on downvoting someone for missing the sarcasm. We're in a public forum which crosses cultural boundaries. I see the argument for both sides.

Although I lean more towards downvoting as the majority of people on HN will get the joke and it's an opportunity to learn for those unfamiliar with the mainstream culture.

(comment deleted)
The eight spaces companies are clearly flying high and the place to be if you're looking for mad bank.
poor ruby devs and their two-space indentation rules.
Well, white-space is removed anyway in compressed production files...
Warning, the parent post is sarcastic and should be chuckled at.
your comment seems to imply that the article and all other comments are not... I'm confused now.
The article is serious. But I'm guessing there is either something subtle wrong in the analysis (they even find Go programmers who use spaces earn more, which makes no sense given that 99% of Go programmers use tabs), or it's some kind of weird selection bias, given that it the sample is self-selected.
just because it was not posted on april 1st, it doesnt make the article serious.

they are publishing a very limited, informal, unscientific, survey and having fun drawing outlandish conclusions.

if you think this was serious in any way you may want to bring back pirates to counter global warming.

Palapa money
...if you hit ten spaces you might afford a full Palapa forest ;)
I think that a rational sounding inerpretation can be found: all spaces means python programmer (mixing spaces and tabs messes up the indentation), python rulez, therefore high salary
Spaces over tabs is the default for IntelliJ. Given there are over ten million Java developers who are in very high demand, Python is practically a rounding error.
Also, they controlled for language and the effect was still present.
The only thing they didn't control for is Stack Overflow use.

It's official: science proves that highly paid tab users just don't need it.

According to the article, he tried controlling for language and the effect remained.
While your comment is obviously meant as a joke, it somehow rings true from my anecdotal experience.

I'd also like to see an analysis of space-vs-tabs as it relates to operating systems. Again, from anecdotal experience, it seems spaces are more common for folks with *nix background who tend to work in product-oriented companies (i.e. where code is an asset) and tabs are more common with windows folks, who tend to work on IT (i.e. where code is liability)

This is...this is actually brilliant logic.
I'd like to add my own anecdote: Windows development primarily happens on one vendor's IDE - Microsoft Visual Studio, and where MS leads, Windows-based developer follow.

Case in point - I use the default Visual Studio settings which are spaces, BUT they weren't always. I remember as recently as 2008 tabs were the default.

Visual Studio 4-6 (1996-2000) the default was tabs
The good years for Microsoft.. feels like there’s a story there :)
(comment deleted)
Hmmm...

I've mostly only ever worked in Windows environments with the odd linux machine here and there, but mostly Windows, I've worked in both I.T. and product-oriented shops. I've mostly favored spaces. I've never been questioned it or asked to do differently. Generally speaking, those that care about the money, don't give a fuck about whether I use tabs or spaces. I've worked in tight-ass shops that have nickeled and dimed for every cent savings and I've worked for shops flush with cash to pay developers to do it right.

In my actual experience, I've never seen any relation to tabs vs. spaces with regards to being paid more. Nobody that has ever paid me for what I do has cared about which I use, nor have they questioned it.

One thing I have noticed in programmers are an asset vs. programmers are a liability is that companies who understand that automation is going to extend their profitability by more of a margin than it costs them will pay you what you're worth. Those that view programming as a sunk cost, that just makes their lives easier or cuts costs will pay you what they can get away with.

Don't work for a company that views you as a cost centre. Work for a company that views you as a profit centre. The work will be more meaningful. You will be more fulfilled. You will most likely be less stressed and you will most certainly be appreciated and respected more.

Windows itself is indented with spaces.
Because the code of Windows is the asset ;)
> product-oriented companies (i.e. where code is an asset > IT (i.e. where code is liability

You got it backwards. In companies that sell code, code is an asset. In companies that sell services code is a necessary evil.

I think you misunderstood him/her.

If you're a software developer and you're part of the "IT" department, then you're a liability. Your code is a necessary evil.

If you're not part of the "IT" department, then you're working in a product-oriented environment where the company is selling your code (either as a good or as a service) or otherwise making money from the code. In that case, your code is an asset.

I've always understood it as functionality is an asset and code is a liability. The company wants and uses the functionality to make money. Code has to be maintained, has bugs, etc. Your goal should be to provide the required functionality while reducing the costs incurred by your code.
Most of the time I've seen people refer to code as a liability, they aren't referring to the 'cost-center' mentality, but rather recognizing code is the liability you incur in order to get the business value [1], and thus you should minimize the code you write per solved business problem.

[1]: https://twitter.com/tastapod/status/726747175317852160

(comment deleted)
So you're saying that if I spent 30 minutes learning fmt then I can expect a raise? Sold!
This is one of the funniest comments I've read on here. This deserves more recognition
This is one of the many unconstructive comments
"The model estimated that using spaces instead of tabs leads to a 8.6% higher salary".

So the model actually predicts causality, instead of correlation? That's amazing. I'll start using spaces instead of tabs today and I will ask for a 8.6% raise.

According to this model, I should get it!

Join a basketball team, you'll be taller too!
As a spaces user, I have to acknowledge that I get irritated when I open a document with tabs and the formatting is messed up thanks to tab setting mismatches.

Is it possible that tab-aversive people making hiring decisions act on their aversions (consciously or unconsciously), while tab-friendly hiring managers do not?

Can you explain that? I can't see how different tab settings would mess up formatting. Unless you use tabs to match the position of things over two different lines (which is abusing tabs), or mix spaces and tabs, tabs should work fine.
If I'm using an IDE that handles whitespace and indentation am I using spaces or tabs?

If a tree falls in the forest, etc

Maybe it's an age thing : older devs tend to prefer spaces and are usually more paid than young devs.
They explicitly rejected this explanation after controlling for years of experience.
age != years of experience
That statement is correct, yet the commenter mentioned two variables who are caused by years of experience and are only correlated with age.
Interesting how multiple people presumed that older devs prefer spaces, which seems like the opposite to me. Tabs are a thing of the past, people used to use them a lot, and now they are relatively rarely used.
Older people use spaces. Older people make more money because they are further along in their career. Thus it only appears spaces make more than tabs, when it's really about age.

Just a guess.

The graph has experience as its y axis.
Ugh. I'm old and and can't see without my glasses.
years of experience != age.
They are, however, correlated :)
This is the third time I've noticed that people didn’t read the article closely enough to note that this explanation was explicitly rejected after the author controlled for years of experience and the effect was still present.
Good thing things like YAML have now trained me to only use spaces. Also for those looking to make a quick buck, emacs has `c-x h m-x untabify` enjoy

   ;; if indent-tabs-mode is off, untabify before saving
   (add-hook 'write-file-hooks
              (lambda () (if (not indent-tabs-mode)
                             (untabify (point-min) (point-max)))
                nil))
is pretty sweet if you are lazy.
Makefiles have taught me the opposite.
What if you control for the size of the space bar and the size of the tab key?
also rubber dome vs switch vs topre
First thought: perhaps languages that officially recommend spaces (e.g. Python) predict higher salaries compared to those that recommend tabs (e.g. Go)?
They did control for the programming language.
Possible explanation: Tab vs space is likely to be correlated with technology (C vs Java vs JavaScript) and different technologies pay differently.
I thought that too, but further down the article it seemed that wasn't the case.

I'd like to see the split of age vs tabs and spaces. I'm with a few other people that may say experienced programmers prefer spaces as it causes them less formatting issues over time when working in larger teams or on differing IDEs - and experience pays more.

This does not mean that changing from tabs to spaces will increase ones income.

I would expect there simply is a confounding factor that the author did not look at. Maybe the info is not in the data.

I can imagine that the space/tab choice is related to the "upbringing" of the developer. Maybe which language or editor they used first in their life.

Or maybe it's related to culture. For example when using IRC, tabs are usually not used to communicate. Maybe that impacts the general choice of tabs/spaces.

Or maybe more sophisticated users tend to exchange the tab key for something else:

https://xkcd.com/1806

Yes, eg. many languages have spaces conventions formalized and those languages may pay more to develop in.
This is already accounted for in the article, the data seems to indicate this even in the same language, and consistently does so across all languages.
The effect in the data (unless it isn't random fluctuation. At the moment I'd go with the assumtion that it is a genuine correlation, as the effect is present over all subgroups), might (1) not be monocausal, i.e. a combination of contributing factors like development experience, age of IDEs/tooling, etc. might play a role as well as other aspects. (2) a cause might not be "explained away" because the control variable was considered. Let me elaborate

The years of experience variable might be taken to explain away the effect of experience, and then conclude that tabs vs. spaces must be due to another effect than years of experience. But chances are, that "years of experience" and "tabs vs. spaces" are just correlated to a common, causal property (like "programming proficiency" or however you want to call it). Both "years of experience" and "tabs vs. spaces" are then just incomplete reflections of the underlying cause, both rendering the effect of the underlying cause incompletely.

What I am trying to say is: Its complicated, probably you won't be able to find the one true cause for the effect in the data. If this were physics, one could come up with a predictive theory to put this to the test. In social studies, we just cannot control the parameters well enough.

If you are interested in reading more on this, "Causality" by Judea Pearl is a good (but exhausting read).

If you hit Tab in Notepad and hit save you get a file with tabs.

If you hit Tab in IntelliJ or a related IDE you get a file with spaces.

If you hit Tab in an older version of VS (the kind you'd expect in certain types of settings where high pay is not usually expected) you get tabs, but in newer versions you get spaces (with defaults)

Unless the project you're working on has an Editorconfig file and your IDE supports it (VS and IntelliJ do by default).

In this case it is supposed to override your IDE settings.

But that just contributes to the gap, the kind of place that devotes time to things like shared editor configs is the kind of place with enough money (and interest) to contribute to development quality, and places like that probably pay more.

The average "sweatshop/devshop" developer probably doesn't even know/care about tabs vs spaces.

Nah, they all give you tabs once you set them up correctly.
I set tab to call auto-indent or the language formatter on the code. I literally hit tab once to insert whatever is the defined standard for the file. So my single tab key press inserts or removes exactly the right amount of white space.

It's a holdover from my emacs days; the one thing I could not give up from emacs...

It may also hint at the years & depth of experience & skillset.

Those who grew up in a shell often ended up building a much more diverse set of skills, the commonality of which is a lot of text based files with a favourite editor.

This extended to using tools like IntelliJ, Eclipse, etc.

Hope a follow up of this study can include the IDE's and if that has some say in this.

Yes, but since it's a human situation, you can reverse the causality link. Imagine people use spaces for an underlying reason that gives them naturally a higher salary, like Harvard Legacy applicants are taught to use spaces, they don't become wealthy because they use spaces, but because their parents were wealthy. And wealthy people hire the kids of other wealthy people with big salaries. Clearly there is no space => big salary.

If you are not born in the nobility that uses spaces, but if at first contact the people in power see you using spaces they might assume you are born a noble, and lower their anti-commoner guard for you and you have a greater chance of entering the nobility without a proper title (don't forget to slam the door after you, nobility only works on exclusivity).

So there is a path for taking the implication completely backwards and still reaching the expected outcome.

It could work if the confounding factor is the one you described. But it would probably backfire if the confounding factor is which language you learned first.

Then forcing yourself to use spaces might reduce your productivity, your self-esteem and your mood.

Kidding aside I rather doubt anything really believes there is a causal relationship between one thing and the other.
I mean in general, sure. If correlation does not imply causation then really, what does??
The first place I would look is size of dataset and correlation effects from multiple self-reporters working for the same company.

Big companies tend to pay more in the software industry. Big companies also tend to have standardized on tabs or spaces internally to simplify the problem of merging code across developer teams. So if you find out that, hypothetically, Amazon, Microsoft, Google, and Facebook have all standardized internally on spaces, that alone could account for the data.

Tab is usually three spaces, right? So if I hit the tab key, I'm getting three button presses for the price of one. So extrapolating from that, if I hit tab I can get my work done three times faster and get out of the office quicker. If I'm using space, it takes me three times longer, which makes the boss think I'm working three times harder and I get a pay raise. I'm always at the office before she is (to fill in all the spaces) and I'm at the office after she leaves (still jamming that space bar). Sure the guy who uses tab ships code faster, but it must be worse code because he obviously rushed through it.

It looks good that I'm such a hard worker. So I get paid more.

A quality analysis, but you're neglecting the wear on your space key. Managers tend to look askance at wasting capex, so I'd recommend taking that in to account.
With the beauty of BYOD, they don't have to worry about it anymore! It's the employee's own keyboard!
If I had to guess, developers who pay more attention to corner cases and/or carefully consider the secondary and tertiary effects of a design choice will tend to choose spaces.

- "TABS WORK GREAT FOR ME" -> First-order effect

- "If someone else views this file with a different tab width preference, the indenting will match their preference" -> Secondary effect

- "If users' preferences can change the indenting of a file, then vertically aligned elements will align or misalign depending on who's viewing it and who wrote it." -> Tertiary effect.

- "Randomly broken formatting and/or forcing users to constantly change their personal tab preferences is a bad way to work with code" -> Quaternery effect, etc.

In other words, a whole-system view that accounts for interactions with other decisions might lead you toward using spaces, while an immediate "local" view might lead you to choose the thing that seems most convenient right now.

I'd rather see the results for those that don't participate in SO surveys: those making $200-500k.
This may or may not be true, but just FYI the salaries were an optional part of the survey so those people may have chosen not to give their salary for some reason or another.
I think the implementation is that those who are high earner don't have time/desire to participate in SO surveys, not that they are unlikely to state their income in SO surveys.
File > Preferences > User Settings > Tabs place two spaces
I've been using prettier.js in my JS projects for a few months and honestly I can't imagine going back to formatting my own code. It would be like making all of my own clothes or something. Who has time for that?

The Go community was on to something with gofmt (even if they did decide on tabs).

I tend to agree, but aren't most of the new hot languages whitespace sensitive? Are there formatters for those kinds of languages?
No, whitespace-sensitive languages are still generally the exception (except newlines). In fact I can't think of a new language that is vaguely popular and whitespace sensitive since Python. I guess there is YAML but that isn't a programming language and is also a bit mental.
Haskell is (slowly)growing in popularity, and F# is whitespace sensitive, and these are (for better or worse), the only languages I touch nowadays.

I suppose that maybe none of the really popular languages follow this though...my bad.

Ok, here's a question I've been wanting to ask someone steeped in syntactic-whitespace languages. Do you find that two developers typing the same code will format it the same way? How much would an auto-formatter change in your team's code?
There has been a bit of friction on that very point...Now we just agree on "four spaces all over the place".

I know for a fact that an auto-formatter like `gofmt` or something would have avoided at least one argument, so it would probably would make the code better in some respects.

That said, I like the whitespace. I like that it forces you to think about how the code is formatted and it tends to make the code a lot less verbose.