The big news this week (other than all that political news) is objective data in the ongoing battle of Tabs vs Spaces. Stack Overflow’s annual developer survey uncovered an interesting correlation: collectively, devs who use spaces are earn more than those who use tabs.

salary_graph-1-1400x1000

That is sure to add some fire to never-ending war, but what if the data is bad? What if people don’t actually know which camp they’re in? Stay with me here.

To explain, first some back-story. Computers cannot actually deal with letters. Oh sure, it looks like you are reading letters on a computer, but they are actually numbers. Just like a kid’s A=1, B=2… cypher, computers represent letters as numbers. In the case of ASCII, A=65, B=66

So, when it came time to indent code, there were a couple obvious choices: space (32) or “horizontal tab” (9). 32 (space) was attractive because it was obvious, 9 (tab) was attractive because it was a single character that could be configured to be any width. The ultimate winner was anyone who could figure out how to turn this stupid nerd fight into pageviews – like me and Stack Overflow. Even Silicon Valley weighed in:

But what if… people didn’t actually know which one they use?

A lot of code editors recognize that people want to insert 32 four times when they press the “tab” key on their keyboard. These are frequently called “soft tabs”. With that setup, a person presses the “tab” key but inserts four space characters (32). Do these devs really think they are in the tab (9) camp?

When I first heard this theory from my friend Adam Kaump I was incredulous. But, it turns out there is evidence for this line of thinking:

Here’s someone who is saying that if you are pressing the “tab” key then you are in the “tab” (9) camp. Even if your editor is inserting four 32s.

Another someone else who apparently thinks that the argument is about which key is pressed, not 9 vs 32:

Doesnt using spaces to indent code waste a lot of time? I mean sure if you’re only indenting once, it takes a few extra key presses to make 1 tab worth of space bar clicks but if your code gets really deep, then you’re talking about wasting a lot of time hitting the space bar key per indent PER line…each subsequent line of indented code doubles the amount of space bar clicks…

Could it be that many who think they are in the Tab Camp are actually on Team Space? If anyone has any more examples of this line of thinking, please leave them in the comments.

As for me, I’m happy to be on the right side of this debate, and urge all devs to turn on their editor’s “visible whitespace” feature.


3 responses to “Tabs vs Spaces: Are we even arguing about the same thing?”

  1. I find it hard to believe that programmers don’t understand the distinction between tabs and spaces, but then again I have met a lot of programmers who don’t understand the difference between a binary number and an ASCII numeric character.

  2. As for me, I’m happy to be on the right side of this debate, and urge all devs to turn on their editor’s “visible whitespace” feature.

    Yes! +1 :thumbs_up:

Leave a Reply