BenCodeZen

So I Converted to Tabs...

For those who watch Silicon Valley, you might remember this hilarious scene where Richard is dating a girl who uses spaces instead of tabs and there's hilarity that ensues as they do work next to one another. Now, this is a topic that plenty of developers have gotten plenty heated over. And while I love an enthusiastic debate over little details like this from time to time, it's certainly not one of those things that I'd be willing to die on a hill for. Nonetheless, I wanted to write a post about my history with the topic and why I ended up on tabs.

As you can probably tell from the title, I used to use spaces for coding. In fact, I was pretty set on it because the reasons for using spaces were "obvious." For the record, I liked to use four spaces since it meant clearer separation of child and parent elements. I wasn't too concerned as far as two spaces in JS, but I used four on my files to be consistent across everything.

The reason I liked spaces at the time were for the following reasons:

  1. Code styling is consistent across all text editors / rendering engines like git code comparisons
  2. As a result, you never have to worry about your code looking like a mess due to different interpretations on tabs
  3. You could control the way your code looked down to lining up individual characters

Looking back at it, it ultimately boiled down to: I could be OCD about how everything looked and obsess over tiny details in how the code showed up on someone's screen. Whether I knew it at the time or not, code to me was a form of art and I wanted my canvas to look exactly the way I liked on everyone's screen.

However, as fate would have it, I would eventually join a team where the discussion for tabs vs spaces came up. And much to my chagrin initially, I learned that most of the team preferred tabs. Now, for the record, there were no heated arguments or emotional raging about how I would quit the team if we didn't use spaces. Whether you believe it or not, we had a civil discussion and they brought up the following points to me:

  1. By using tabs, we have a standard unit of measurement for indentation
  2. If we use spaces, then a second argument has to be had regarding how many spaces to use
  3. Tabs allow the user to change the size of the indentation based on their preference

Though I didn't realize it at the time, the reason I liked spaces was really all about me. It wasn't until their third point that I realized how selfish it was for me to try and fight for the spaces camp. After all, who was I to determine what someone else viewed as more legible or easier to parse? And if it means everyone can work with what they're comfortable with, who am I to say no to that? It was then that I realized tabs was the friendlier and more compassionate side of the two.

So to me, other than the scenario where the entire team happens to love spaces and can all agree on one standard, I think tabs has won the war when it comes to collaborating with other people. Because after all, what matters at the end of the day is that we're building interesting products that we are proud to ship and not whether our source code contains spaces or tabs for indentation.