from Hacker News

Developers Who Use Spaces Make More Money Than Those Who Use Tabs (2017)

by amin on 5/17/21, 7:55 AM with 259 comments

  • by srl on 5/17/21, 8:18 AM

    This is a huge effect. Implausibly huge? I'm reminded of Gelman et al's piranhas: http://www.stat.columbia.edu/~gelman/research/unpublished/pi.... The "folk theorem" version is that you can't have very many independent variables that all have large effects on salary. Saying that spaces vs tabs has a 10% effect is tantamount to saying that its one of the ten (or fewer) most important things about a developer.

    So there must be a confounder. What could it be?

    - Do the top schools all instruct students to always use spaces? This should have been partly taken care of when the author controlled for level of education though, right?

    - Choice of editor? This seems like a weird one, but editor defaults are definitely linked to tabs vs spaces, and the survey didn't even collect data on this.

    - Starting language?

    - Total number of languages used? Spaces are tolerable in more languages than tabs are. Of course, I'd expect "both" to beat "spaces" if this was the case.

    None of these strikes me as particularly plausible, except maybe the last one. This result is kind of bothersome, because it's big, obviously not a statistical fluke, and hard to understand.

    EDIT: a past thread (https://news.ycombinator.com/item?id=20719010) suggested that some higher paying companies mandate spaces. This also seems plausible.

  • by kstenerud on 5/17/21, 8:42 AM

    I settled on spaces long ago for the following reasons:

    - Tabs move the cursor to the next "tab position" but are invisible, which means that whenever someone hits tab in the middle of something (accidentally or otherwise for alignment), you end up with messed up looking text and alignment as soon as you view it with a different tab size.

    - Trying to enforce "tabs only for indentation" rarely works without headaches because humans.

    - Using monospaced characters everywhere means that you'll never encounter positional issues ever.

    I've worked in 2-space, 3-space, 4-space, and 8-space indentation houses and honestly, I don't see the point of viewing indentation in your preferred size. It's easy to adapt to the house rules, and the benefits outweigh the headaches.

  • by mg on 5/17/21, 8:32 AM

    In theory, tabs for indention and spaces for alignment would be the best way to handle whitespace.

    Unfortunately in practice, two factors are in the way:

    1) Most developers are confused by this type of whitespace usage. Simply because it is the less popular practice. So when you have a codebase that uses tabs for indention, you get more broken commits from developers who stumble in keeping the system intact.

    2) Out of the box, VIM has no easy way to colorize tabs. So when you look at your code, tabs and spaces look the same. You cannot say from just if the whitespace is ok or messed up. You can show all non printing chars with "show list" but that is not very nice on the eyes. Or you can configure "show list" to only highlight tabs but then you lose the ability to show all non printing chars.

  • by strogonoff on 5/17/21, 8:49 AM

    My pet theory is that the preference for spaces comes from people who want their codebase to be equivalently readable in any editor right off the bat. With tabs, depending on editor configuration, the same codebase could look fine on one machine and be a mess on another.

    Furthermore, I believe that with certain indentation styles (e.g., when arguments in a function call align with the opening paren) tabs require that one extra preliminary step of configuring one’s editor in order to view the code properly, while with spaces that extra step has more optionality and is only needed in order to edit the code with auto-indent.

    IMO since one has to adapt their coding style to the dominant style of the codebase (single/double quotes, etc.) either way, one might as well adapt to the indentation as well, so I’m not against spaces.

    And of course, due to people who don’t take care to set up their tooling and end up mixing tabs and spaces for indentation, a particularly hot mess can arise—and what’s worse, that mess can accidentally look fine in editors that happen to be configured in a particular way. Because of that, I keep whitespace visibility turned on across my editors.

  • by xdrosenheim on 5/17/21, 8:07 AM

    This is clearly because people who use spaces, lie about their income.
  • by elihu on 5/17/21, 8:15 AM

    I think there's a general trend where C programmers generally are near the bottom in terms of salary, and I think a disproportionate amount of C programmers probably use tabs (due to the popularity of the Linux kernel style).

    Or in other words: I know who's pulling down the average because it's me.

  • by eckesicle on 5/17/21, 8:29 AM

    I suspect that this is partially caused by the fact that 'spaces' is the non-default choice in many standard IDEs such as Eclipse and the rest of its enterprise friends.

    Software engineers who make active choices in their setup rather than just accept default configurations and tools tend to be better at other aspects of their job too?

  • by nyuszika7h on 5/17/21, 10:31 AM

    There are plenty of reasons for preferring spaces:

    * There will always be that one diff tool/website which doesn't support configuring the tab width and renders your code with 8-space tabs. Even if every tool you use supports configuring this, it's going to be a nightmare to configure every single tool when the default of 8 is not sane for the majority of people.

    * If you enforce a maximum line length for your code, people who use a different tab width than you are bound to mess this up. I mean, you can somewhat avoid it with an automated linters, but then again, which tab width do you set it for? If you set it too low, it will look bad people with bigger tab widths working on a split screen. If you set it too high, code will be unnecessarily wrapped everywhere and it will look bad.

    * Mixing tabs and spaces to ensure proper alignment of function arguments with any tab width can be a nightmare. Someone on your team is definitely going to mess it up eventually, and you'll have to clean up after them. With spaces enforced, indentation and alignment will look the same everywhere and mistakes will be immediately obvious regardless of the tool used for code review. (Editors may support differentiating tabs visually, but I don't think GitHub or GitLab does.)

    On a team project, you don't get to choose other things like brace style either. You just have to learn to deal with it. There are too many variables to account for, such as the ones I mentioned above. Using spaces ensures consistency everywhere.

    In an ideal world, you wouldn't have to worry about all this, you would just store a minified version of the code and your editor could format it with your preferred tab width, line length, brace style, etc. But in reality, it's not that simple. Auto-formatters are far from perfect.

  • by FriedrichN on 5/17/21, 8:16 AM

    It might have to do with the fact that people who use tabs have stronger principles (indentation should be one char!) and people with strong principles will generally have more conflicts with their colleagues and bosses. Usually conflict isn't good for salary negotiations or keeping a job.

    That's my 100% unscientific, non-evidence based guess.

  • by maury91 on 5/17/21, 8:14 AM

    Joke: Devs are paid by how many buttons they press, devs who use spaces press the spacebar a lot!
  • by totalZero on 5/17/21, 8:12 AM

    I'm surprised they didn't normalize for age, which is correlated with income up to a certain point and then drops off.
  • by benrbray on 5/17/21, 8:11 AM

  • by isitdopamine on 5/17/21, 8:12 AM

    Since some very popular languages (Python) actively discourage using tabs, this is most likely related to a difference in language choices, rather than in a genuine indentation preferences.
  • by tffgg on 5/17/21, 8:08 AM

    My editor and IDEs convert tabs to spaces...
  • by pitched on 5/17/21, 8:07 AM

    I’ve noticed this before too! I think it’s because spaces are just lazier. Tabs might be more flexible but they do take a bit more effort. Someone who puts more effort than needed into one thing won’t stop at tabs.
  • by paulolc on 5/17/21, 2:50 PM

    Don't get lured by the Dark Side! Accessibility is the real reason you must use tabs instead of spaces for indentation [1]. Yes, it's evident that Accessibility is not valued and that it's easier/cheaper to not care. We should start to care. Maybe it doesn't even cost that much. Just by flagging it on formatting commit hooks or in some plugin in static analysis tools like Sonar, would go a long way in raising awareness and improving this.

    Developers with visual impairment have different needs regarding indentation. One could need a tab-width of 1 due to the use of gigantic font size and the other a tab-with of 8 because of a wide monitor.

    [1] Nobody talks about the real reason to use Tabs over Spaces https://news.ycombinator.com/item?id=20381027 https://news.ycombinator.com/item?id=20341354)

    Previous threads https://news.ycombinator.com/item?id=20381027 https://news.ycombinator.com/item?id=20341354

  • by cryptica on 5/17/21, 8:44 AM

    I use 2 spaces for indentation, but I agree that tabs are more logical. The reason why I switched to using spaces (years ago) is because tabs look terrible when copy-pasting code in a text area in the browser; they look way too big.

    If everyone chose tab spacing sensibly, then tabs would be ideal but there always seems to be some people somewhere who will exploit any flexibility provided by any technology to do something retarded.

    At least with 2 spaces, I have full control over how my code looks everywhere.

  • by vishnugupta on 5/17/21, 8:28 AM

    Maybe the causality is inverted?

    Instead of saying international athletes are more likely to use Nike shoes you end up saying Nike wearers are more likely to be international athletes.

  • by ybbond on 5/17/21, 8:03 PM

    Actually, I like tab. It gives people more choice on how their code looks like based on their editor's preference.

    But no, I cannot —even sneakily, manually— enforce tab in my company(es) code bases. Reasonable person uses formatter which opinionated config set from the first commit.

    And I like the formatter decision better. If it is automated and reduce unnecessary debate between devs, why not?

  • by junon on 5/17/21, 10:34 PM

    If I recall, someone mentioned this was probably because the majority of IDEs come pre-configured to use spaces for indentation over tabs. Therefore, the study is skewed as most people don't update their IDE settings unless they're particular about them (IME this sounds like it's true).
  • by kodah on 5/17/21, 11:07 PM

    Why do people try to put accessibility arguments on people rather than doing this intelligently per language in the IDE? The functions to convert tabs and spaces (not mention how to represent them) is entirely configurable already. Is there something I'm missing?
  • by mfbx9da4 on 5/17/21, 8:20 AM

    Correlation does not imply causation but very fun title!
  • by u801e on 5/17/21, 10:26 PM

    Using hanging indents works regardless of whether one uses spaces or tabs. But trying to align text based on the indentation of the opening parenthesis (of it's on the same line as the method name) pretty much only works well with just spaces.
  • by mikewarot on 5/17/21, 7:29 PM

    [Edit: Personal Usage] I use space within text, and TAB/Shift-TAB to move between data entry fields. You never know when a TAB key is going to do something weird outside of your home IDE. [/EDIT]

    They missed an axis.... sure you can compare Space vs Horizontal Tabs, but what about Line feed vs Vertical tabs? Form feeds are similarly overlooked.

    Also missing is the lf / cr-lf debate 8)

    PS: Does anyone use Group, Record, or Unit Separators?

    Reference: https://theasciicode.com.ar/ascii-control-characters/vertica...

  • by Yizahi on 5/17/21, 9:18 AM

    Did anyone seen actual "broken" indentation on any system in the last 10 years? (specifically indentation, not mid line breaks filled with tabs) Because that is the only argument for spaces.

    Personally, I sometimes log onto very old boxes running some old OS and s/w, and I've never seen broken indentation display for tabs.

    I think replacing tabs with multiple spaces was a valid solution in 20th century, but not anymore for last decade at least. Instead it transformed into a cargo cult like obsession, with zero valid reasons today.

  • by dang on 5/17/21, 7:23 PM

    Some past threads:

    Developers Who Use Spaces Make More Money Than Those Who Use Tabs (2017) - https://news.ycombinator.com/item?id=20718031 - Aug 2019 (148 comments)

    Developers who use spaces make more money than those who use tabs - https://news.ycombinator.com/item?id=14560042 - June 2017 (663 comments)

  • by globular-toast on 5/17/21, 8:35 AM

    I'm someone who uses spaces, but knows I should be using tabs.

    In other sad missed opportunities, see the ASCII delimiters: https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text

    That's right, four levels of delimiters, built in to ASCII! No unicode required. Instead of that we get CSV, with in-band delimiters and the resulting god awful quoting rules that go with that.

  • by Stranger43 on 5/17/21, 2:55 PM

    The question here is what space vs tab use is actually an proxy, which is a question you generally need to ask when you get weird but valid statistical results.

    If there for instance was an correlation between having lived though the bad old days with primitive build/formatting tool chains and a preference for spaces that would easily explain a difference in salary that have nothing to do with the argument for/against tabs/spaces as it relates to modern tooling.

  • by hankchinaski on 5/17/21, 9:19 AM

    Chocolate consumption per capita is positively correlated with the stock of Nobel prizes per capita [0]

    [0] https://www.sciencedirect.com/science/article/pii/S259029112...

  • by mnd999 on 5/17/21, 8:12 AM

    What about developers who follow the coding standards because they value consistency over personal preferences?
  • by EVa5I7bHFq9mnYK on 5/26/21, 8:06 AM

    I use spaces because long ago I had two editors, one of which showed a tab as 4 spaces, and the other - as 8. So spaces provided consistency, that's all. Maybe older developers prefer spaces for that reason, hence the salary gap?
  • by yummybear on 5/17/21, 8:28 AM

    Are there languages that lend themselves more to space-indentation? That could explain the wage gap.
  • by hackerbabz on 5/18/21, 6:19 AM

    I don't even know what I use. It probably changes in different repositories. I've never cared enough to check or set it one way or the other, and definitely don't care enough to have a 20 minute meeting with my team to decide.
  • by mclightning on 5/17/21, 11:00 AM

    Developers who are not stuck on the argument of this duality are making even more.
  • by trog on 5/17/21, 8:51 AM

    Is there a group of developers somewhere that charge per byte of code they write?
  • by renewiltord on 5/17/21, 7:42 PM

    Maybe it’s “Developers who care about tabs v spaces spend more time on that discussion and therefore make less money than those who go with the defaults (all spaces)”

    A.k.a The Market Hates Bikesheds

  • by Ballas on 5/17/21, 9:44 AM

    Might be unfounded, but my personal theory is that the correlation might be something as simple as companies that adopt (for instance) the Google C++ coding style guide pay more.
  • by Threeve303 on 5/17/21, 8:40 PM

    This is why early languages had no white space at all. /s
  • by zelphirkalt on 5/17/21, 8:13 AM

    But how do they write makefiles? hard thinking face
  • by thanatos519 on 5/17/21, 8:15 AM

    Tabs ... of acid? :-P
  • by jl2718 on 5/17/21, 1:41 PM

    In the beginning, there was only tabs, and all indentation was exactly one tab greater than the prior context.

    Then, a few people started doing tabs and then spaces to indent their function arguments to align with the opening parenthesis of function arguments. Why? Because it looks like a windows drop-down menu hierarchy, opening the sub-menu to the right of the selection. These people tend to be UI-focused, heavy PowerPoint users, CS 101 teachers, and management types.

    This was okay when everybody was using MSVC or Visual Basic (no Unix person would do this), and so tabs-then-spaces code crept into everything. Tab purists were at worst mildly annoyed. There was no such thing as a space purist. They would have been physically assaulted for banging on a mechanical space bar that many times in a cubicle office.

    But if you opened up that file in notepad.exe, or wordpad.exe, or TextEdit, or Borland or vi or emacs or any other text editor, you would get a preview of the chaos that was about to be unleashed. When the web became popular, the standard programming environment for a lot of people became “right click -> view source”. Space width was all over the place. Tab width was blowing text off the page. Word wrap was horror, and saving a file in word wrap mode saved the imputed carriage returns.

    But that was still just aesthetics. When python became popular, it changed behavior. Python tried to adapt by allowing many different styles of indentation. It worked most of the time, but not all the time. This is how it turned into a full-on war.

    It is easy to convert tabs to spaces, and hard to go the other way. So naturally, people wrote a simple script to convert tabs to the right number of spaces. Then immediately the number of key bangs rose to a deafening roar. Nerf sales went through the roof as the office became a war zone. The accountants were still using pencil and notebook.

    So people tried to write scripts to convert back to tabs. Hahahaha mortal. You can never go back. Your attempts are futile and the one bug you introduce will be your undoing. Foolish tab purist! Come to the dark side and embrace the space. Yesssss... see that giant bar at the bottom of your keyboard? Hit it! Again! Louder! What’s that? You made a mistake? Lost count? Start over! Hahahahahaha!

    Then editors changed to no longer record your keystrokes, but instead try to guess at what you mean and show you what it wants you to have meant. These editors have other great features to churn out reams of code that nobody will ever be able to review or keep up with, which is the key to leading a project and getting that promotion. The worse the code, the more people you’ll have to manage to get it working.

    Meanwhile, tab purists are an exiled minority, unable to find anybody to work with, begrudgingly accepting their orders from some young superstar coder that blew out the git log in their first 30 days on the job.

    Oh the lowly tab purist. Go home and seethe; you are defeated. Watch again one of the five movies you own on your Betamax or HD-DVD. Better standards? Hahahaha!

  • by King-Aaron on 5/17/21, 8:13 AM

    Correlation and Causation something something
  • by d--b on 5/17/21, 8:16 AM

    Wait, there are still people who use tabs?
  • by thenoblesunfish on 5/17/21, 11:31 AM

    Do employers who tend to pay more (e.g. Google) tend to have style guides which encourage spaces over tabs?
  • by hpen on 5/17/21, 11:16 PM

    Just use a code formatter and half the issue highlighted in these comments disappear
  • by alephnan on 5/17/21, 8:17 PM

    Because Google engineers use spaces, even after they leave Google
  • by iamgopal on 5/17/21, 8:20 AM

    Which should be the correct way ? Space or Tabs ?
  • by tmccrary55 on 5/17/21, 8:12 AM

    What about people who use tabs and spaces?
  • by iovrthoughtthis on 5/17/21, 8:22 AM

    where do all the people who use spaces work?

    is one (or some) high paying companies coding practices skewing the results?

  • by alanchen on 5/17/21, 11:22 PM

    Correlation != Causality
  • by abcdasfwe on 5/17/21, 8:59 AM

    i'm a python dev, and i don't agree with this
  • by traceroute66 on 5/17/21, 8:14 AM

    Surely this nonsense is a textbook example of statistical overfitting ?
  • by blarg1 on 5/17/21, 9:18 PM

    What if I use both?
  • by avipars on 5/17/21, 8:47 AM

    What about IQ
  • by Cerebrum1234 on 5/17/21, 9:17 AM

    Programmers who use spaces 'paid more'· Computer programmers who use spaces as part of their coding earn.
  • by wavegeek on 5/17/21, 8:27 AM

    This is because they are

    a) More smart

    b) More correct.

    It is not that complex.

    Also they are more likely to be using emacs, another big win.

  • by raverbashing on 5/17/21, 8:12 AM

    That's like saying people who use "import" clauses make more money than those who use "requires" clauses.

    I don't even know why this is a discussion, if ASCII has a character that represents an indent, we might as well use it (unless you prefer typing & as Et, < as LessThan, etc)

    That being said, yes, using spaces for arbitrary alignment is easier