Slashdot Mirror


Developers Who Use Spaces Make More Money Than Those Who Use Tabs (stackoverflow.blog)

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.

48 of 515 comments (clear)

  1. Pied Piper proves it too ... by drnb · · Score: 4, Funny

    Pied Piper proves it too, that tab loving company is one money losing screwup after another.

  2. Both? by TFlan91 · · Score: 2

    "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.

    1. Re:Both? by BronsCon · · Score: 5, Insightful

      I can actually see the argument for a 4-space indent consisting of 3 spaces and a tab. The developer thinks they're throwing a bone to people who use tabs by allowing them to set their own indent width. But they're wrong to use spaces at all in that case; what about people who prefer 2- or 3-char indents?

      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.

      --
      APK quotes people (including myself) without context and should not be trusted. Just thought you should know.
    2. Re:Both? by edtice1559 · · Score: 2

      What is shocking to me is that we even have this discussion. There ought to be a check-in hook that properly formats the code. Would also reduce defects where a brace/bracket is missing.

    3. Re:Both? by beelsebob · · Score: 3, 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".

  3. Only dummies and newbs argue stupid shit by Anonymous Coward · · Score: 5, Insightful

    Proof: neither side makes jack-shit as a coder

    1. Re:Only dummies and newbs argue stupid shit by JaredOfEuropa · · Score: 2

      Just you wait. I bet a PHB is reading this right now, thinking: "If those coders get paid more, they must be better. So it must be the spaces that makes them better. I should go and change our coding standards". And then demand that you actually use the space bar to produce the spaces, in case you're still sneaking tabs in there somehow.

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    2. Re:Only dummies and newbs argue stupid shit by avandesande · · Score: 5, Insightful

      actually a smart PHB would force everyone to use tabs and give them a pay cut

      --
      love is just extroverted narcissism
  4. Survey says by StikyPad · · Score: 4, Insightful

    If the median salary was under $50k, then I'm not sure who they were surveying, but it wasn't professional developers.

    1. Re:Survey says by drnb · · Score: 3, 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.

    2. Re:Survey says by swillden · · Score: 3, 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.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
  5. Of course they earn more! by DontBeAMoran · · 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.

    --
    #DeleteFacebook
  6. That's because they get paid by the character by JoeyRox · · Score: 5, Funny

    Using spaces increased my earnings by 4x over tabs.

  7. Editor by Slalomsk8er · · Score: 2

    I press tab but the editor inserts whatever the project requires. Did the question account for this?

  8. Did they take language into account? by RobinH · · Score: 3, Interesting

    I'd think that space vs. tab use is highly dependent on which programming language you're using, and I'd also think that language is correlated with earnings, so I highly doubt this conclusion (if they're trying to conclude anything). Correlation is not causation.

    --
    "I have never let my schooling interfere with my education." - Mark Twain
    1. Re:Did they take language into account? by Anonymous Coward · · 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?

  9. Re:Yeah but by Coisiche · · Score: 4, Funny

    Most of the respondents wouldn't have understand the question because they actually use whatever their IDE does.

  10. Eclipse serializes with spaces or tabs by prefec2 · · Score: 4, 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.

  11. Charming and fun, but not informative by TimothyHollins · · Score: 2, 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)

  12. Alternate interpretation of the data by Comboman · · Score: 5, Informative

    Programmers who use spaces are more likely to lie about how much money they make.

    --
    Support Right To Repair Legislation.
  13. OB Scene from "Silicon Valley" by Leomania · · Score: 3, Informative
    --
    You don't use science to show that you're right, you use science to become right.
  14. The real question... by crashumbc · · Score: 5, Funny

    One space or two after a period?

    Sorry wrong crowd :P

    (and don't you heathens dare say one)

    1. Re:The real question... by Anonymous Coward · · Score: 2, Funny

      I always give my wife plenty of space when she's on her period, and for a day or so after.

    2. Re:The real question... by sl3xd · · Score: 3, 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.

      --
      -- Sometimes you have to turn the lights off in order to see.
  15. Possible Explanation... by sycodon · · Score: 3, 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.

    --
    When Fascism comes to America, it will call itself Anti-Fascism, and tell you to give up your guns.
    1. Re:Possible Explanation... by krotscheck · · 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.

      --
      This signature can save you $400 on your car insurance!
    2. Re:Possible Explanation... by donaldm · · 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.

      --
      There ain't no such thing as proprietary standards only proprietary formats. Standards are by definition open.
    3. Re:Possible Explanation... by ShanghaiBill · · Score: 4, 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.

    4. Re:Possible Explanation... by Rockoon · · Score: 2

      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.

      --
      "His name was James Damore."
    5. Re:Possible Explanation... by DrStrangluv · · Score: 5, Interesting

      > 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.

      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.

    6. Re:Possible Explanation... by serviscope_minor · · Score: 2

      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.

      --
      SJW n. One who posts facts.
    7. Re:Possible Explanation... by Gr8Apes · · 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.

      --
      The cesspool just got a check and balance.
    8. Re:Possible Explanation... by ShanghaiBill · · 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.

    9. Re:Possible Explanation... by amicusNYCL · · 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.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    10. Re:Possible Explanation... by 0100010001010011 · · Score: 5, Funny

      Intelligent devs use IDEs

      Would that be vim or emacs?

    11. Re:Possible Explanation... by skids · · Score: 2

      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.

    12. Re:Possible Explanation... by Anonymous Coward · · 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.

    13. Re:Possible Explanation... by greythax · · Score: 4, Insightful

      And truly intelligent devs check the "use spaces instead of tabs for formatting" in the options of their IDE...

    14. Re:Possible Explanation... by SCVonSteroids · · Score: 2

      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!

      --
      I tend to rant.
    15. Re:Possible Explanation... by DickBreath · · Score: 2

      > argument is so 90s, and seems more like
      > arguing whether cow or bull leather whips are better.

      Bull leather whips work better.

      Most employers would agree.

      --

      I'll see your senator, and I'll raise you two judges.
    16. Re:Possible Explanation... by Gr8Apes · · Score: 2

      You've missed my point. IDEs should handle formatting into whatever you wish to see, and the storage format should store code, for which all white space after the initial demarcation is redundant. I personally despise spaces, as I generally have no use for them at all past 1. Tabs are better IMNSHO because they eliminate extra spaces, but they're still not awesome. Either way, my IDE works with spaces and tabs and deals with the formatting as necessary, so a proper project config file removes any formatting issues as far as coding standards of the day go.

      BTW, as far as I'm concerned, any language that is whitespace dependent isn't really a candidate for a usable language. We'll throw that out there as well.

      --
      The cesspool just got a check and balance.
  16. Re:$59,140 and $43,750 are the medians? by 93+Escort+Wagon · · Score: 2

    Yeah, this is heavily weighted towards S/SE Asia - and the fact that spaces versus tabs actually matters to them may say something.

    --
    #DeleteChrome
  17. Re: Yeah but by ranton · · Score: 2

    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.

    --
    -- All that is necessary for the triumph of evil is that good men do nothing. -- Edmund Burke
  18. Re:I use spaces but indent by 2 spaces rather than by omnichad · · Score: 2

    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 comment to see that the space is the same size.

    In Slashdot comments, my double-spacing is rendered in HTML as a single space because HTML only renders one space in a consecutive string of white space. However, I developed that habit out of visual preference - I started typing well after the typewriter era.

  19. On Tabs and Spaces by Qbertino · · Score: 2

    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.

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:On Tabs and Spaces by chefmonkey · · Score: 2

      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.

      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.

  20. Re: I use spaces but indent by 2 spaces rather th by Anonymous Coward · · Score: 2, Funny

    Three spaces? That's ... odd.

  21. Re:Do you have a choice? by bobbied · · Score: 2

    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.

    --
    "File to fit, pound to insert, paint to match" - Aircraft Maintenance 101