Tabs Vs Spaces: The Programming Debate Has A Definite Winner

Fan of HBO's Silicon Valley may remember the episode where Richard was made fun of for preferring tabs over spaces for indentation. Well, it turns out it's no joke - at least when it comes to making money as a developer. Stack Overflow's recent programmer survey revealed an interesting tidbit: devs who uses spaces make around 8.6 per cent more than their tab-tapping counterparts.

As part of its annual survey in 2017, Stack Overflow asked the question: do you use tabs or spaces for indentation? 28,657 answered and of those, 41.8 per cent landed in the spaces camp, while 40.7 per cent ended up as tab users. The remaining 17.5 per cent dabbled with both.

Image: Stack Overflow

Stack Overflow then matched this data with the stated salary of the respondent and well, here are the results:

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.

So, how much can we really draw from this conclusion? Stack Overflow's David Robinson, who did the analysis, correctly points out that "correlation is not causation".

However, despite Robinson's best efforts, he wasn't able to explain the difference, even after "controlling ... many other confounding factors within the survey data":

...it was difficult to make the effect shrink and basically impossible to make it disappear.

Somehow, I don't think switching to spaces right now is going to bump your salary up by close to 10 per cent, but it might be wise to pay your tab-despising comrades a little more respect. They might just be making more than you.

Developers Who Use Spaces Make More Money Than Those Who Use Tabs [Stack Overflow]


Comments

    Spaces are better because it's a universal measurement. The length of a tab can change depending on the font or compiler or even the OS but the length of a space remains consistent.

      The length of a tab is usually configurable in a decent editor, which means anyone can make the code more readable to themselves. If you use spaces for indentation, what is the correct number of spaces for maximum readability?

      I think it's 4 spaces, but many people seem to think it should be 2 spaces, and I find it hard to read their code. The linux kernel code standard says it should be 8 spaces, which I find ridiculous.

      does length actually matter though? if a tab is 2 spaces or 4 spaces, it is another indentation that's the main thing.

      Sitting there hitting the space button 10 times to indent that 3rd nested section feels like a child hammering at a big boys keyboard.

      The length of a space varies as well, depending on the font. Some fonts, like courier, have every character the same number of pixels wide, spaces included.

      That makes the space considerable wider than something like Arial, Times New Roman, or Comic Sans. You can see it in word if you mess about a little.

      The early days of computers meant the default font was courier, which is the basis for a lot of this. 5 spaces was the same as tab visually, so programmers got into the habit of one or the other. As they trained others, one or the other stuck, and we end up where we are now.

      I use both, depending on what I'm working on. I don't think it matters all that much, either does the job of breaking up coding nesting to read easier, which was the whole point in the first place.

    Did they also collect data on where they worked? Big companies like Microsoft or Google tend to pay more, and they have company wide code standards, which may be decided on based on code readability, or may be decided on quite arbitrarily. I think it's a weird logical leap to suggest that the debate "has a winner" based on salary, as that doesn't necessarily mean the spaces approach was chosen because it's actually the better choice.

    I didn't even know this was a 'thing' until just now.
    Wouldn't it be dependent on each companies development or even the teams within?
    My assumption is that 'indenting' is a way to help the human eye read code with better ease, and each coding software, and programmers would have their own preferences and standards based on the development they are doing.
    Wouldn't this change per company and project?

Join the discussion!

Trending Stories Right Now