Spaces, Tabs and Forbidden Love
Ever heard of a breakup caused by indentation? She’s a space cadet, he’s a tabsolutist. Could such a piddling detail spell the end of a relationship? That was the storyline of last Sunday’s episode of Silicon Valley, broadcast on HBO right after Game of Thrones. Richard, the series’ main protagonist, waited until the third season to finally consider romance – we assume that until then, the Pied Piper crew were too busy coding algorithms to take any interest in anything else, girls included.
Richard walks into a bar and meets Winnie, a lovely young lady who is too good to be true: she codes, studied at M.I.T., works for Facebook, and has a GitHub account. But the lovebirds are not a match made in heaven: while Richard is a space evader, Winnie is a tabominator. As the pair nestle on the couch with their laptops,
courting coding, all hell breaks loose: Winnie conspicuously uses the space key to indent her code. She feels Richard oozing disapproval:
— Your roommates were right, you really hate spaces.
— No, no, no. I don’t, it’s not hate, hate’s a strong word. Um, truth be told, I do have a slight preference for tabs. But that’s only because I’m anal and because I prefer … precision. Well, not to pick a fight here, but if you really care about precision, why would you use spaces?
Winnie is a pragmatist:
— Once it goes through the compiler, it’s the same thing. Right?
— Yeah. Yeah, technically yes. I guess, I just… I just don’t understand why you—anyone would use spaces over tabs. Like, if it’s all the same, why not just use tabs?
— Because it could look different on other people’s computers.
— Tabs create smaller file sizes, all right? I run a compression company, trust me, I’ve devoted my life to minimalizing file sizes. It’s what I do. I mean, I do not get why anyone would use spaces over tabs. I mean, why not just use Vim over Emacs? (CHUCKLES)
— I do use Vim over Emac.
— Oh, God, help us! Okay, uh … you know what? I just… I don’t think this is going to work. I’m so sorry. Uh, I mean like, what, we’re going to bring kids into this world with that over their heads? That’s not really fair to them, don’t you think?
— Kids? We haven’t even slept together.
— And guess what, it’s never going to happen now, because there is no way I’m going to be with someone who uses spaces over tabs.
An edifice months in the building, laid asunder in just a few ruinous seconds! The Gods were smiling benignly upon him, the muses were tuning their lyres, but lo! what ill-fated words escaped his mouth? Tabs over spaces… you just can’t take that kind of stuff back.
A battle to the death… and beyond
Code indentation is first and foremost a question of presentation, save for a few rare languages, such as Python, that use indentations made up of spaces to replace curly brackets.
Most of the time, indenting is optional and has no bearing on the proper functioning of the program. It is above all a visual aid to make it easier to read and debug code. Spaces or tabs: six of one and half a dozen of the other. But as polarizing as Mac vs. PC, Pepsi vs. Coke, Xbox vs. PlayStation, and of course Vim vs. Emacs.
If spaces guarantee consistency from one machine to the other, while tabs are more economical, is it really necessary to get all worked up over an individual preference? YES! The codiverse agrees on this at least!
If tabbers make a temporary alliance of convenience with spacers, it’s to defeat their common enemy: the “mixers”, who freely pepper their code with BOTH. And even they will show a united front against the lowest of the low: the double-crossing NON-INDENTERS.
This emotionally charged disagreement goes ballistic when passive-agressive types, while reviewing code, treasonously insert tabs in space-indented code, or vice-versa. The message is loud and clear: “F.U.” True, modern coding tools allow you to reformat, clean and tidy code according to your preferences, but that doesn’t change the fact that the unspeakable churl violated and sullied the unalloyed perfection of your work. He’s out to get you.
Another toxic personality is the “formatting nazi”. He owns the truth. He decides what is good or bad, right or wrong, good or evil, pure or impure. He decrees not just indentation style, but every last detail of coding such as naming variables. He is to programming what “grammar nazis” are to language. Sure, we’re all for more readable, consistent code, but there is a time and a way to do things.
Getting back to Richard’s case for precision, even that is arguable, since tabs can be rendered by a variable number of spaces, depending on the platform, the software or even preferences. In other words, tabs are not consistent. Further, they can cause problems when code is pasted into word-processing software such as MS Word, for example when producing documentation. In this case, tabs are no longer made up of a set number of spaces, but are set at an arbitary, variable distance from the left margin.
In fact it is no longer necessary to hit the space bar four times to get four spaces, since modern development environments (“Integrated Development Environment”, IDE) allow you to set your tabs at a predetermined number of spaces (3 or 4, for example). Winnie seemed to be unaware of this, unless she was just trying to get Richard’s goat, or to test his (narrow) limits.
“Choose tabs, choose spaces, choose whatever layout conventions make sense to you and your team. It doesn’t actually matter which coding styles you pick. What does matter is that you, and everyone else on your team, sticks with those conventions and uses them consistently. That said, only a moron would use tabs to format their code.”
— Jeff Atwood.
Who can argue with that… but isn’t it obvious that tabs are an aberration? That they are a source of solitary titillation of octet counters like Richard or of screwballs who insist that ASCII code 9 has semantic value? It is interesting to note that tabocrats such as Richard are often control freaks:
“Tabs are 8 characters. They are NOT adjustable. Never have been, never will be. Anybody who thinks tabs are anything but 8 chars apart is just wrong. It’s that simple.”
— Linus Torvalds, 19 Jan 2001.
Whatever your proclivity, if your latest conquest codes, do make discreet enquiries about their formatting orientation sometime between your first and second dates; you don’t want to find out when a baby is on the way.
You like this article?
Don't miss one!
our weekly newsletter.