tabs vs spaces

So you just got off your computer after some idiots on IRC were having a lengthy discussion over why spaces are the better format of indentation over tabs. Some might argue that with spaces the programmer can decide how the user should view their code, others say that mashing their spacebar hundreds of times is just better than pressing tab. Here's my take on this controversial topic.

Why spaces are better

The code looks the same on every editor

8 spaces? Seriously vim, 2 is a maximum.

Works perfectly with microsoft word

When programming in microsoft word, the tab key will make the text align with other tab spaces, which won't work well when they are not aligned correctly.

Better for your keyboard

The spacebar key is a lot more reinforced than the tab key, since tab was designed long before the invention of programming, and wasn't designed to be constantly used to indent code.

Why tabs are better

Anyone can choose the tab width

Some prefer 2, some prefer 4, and theres probably someone out there that even prefers 8 char widths. This makes it easier for collaboration.

Uses less disk space

Since tab is only one character, the disk space consumed is much less than space indented code.

Editors support them

Fire up any real editor and notice that it will automatically indent the lines for you. Even editors that do not support this will have a plugin for it somewhere. Support for space intentation is a lot rarer


So as you can see the evidence highly leans towards tabs being better. End of argument.

Back



side note: some of my repos use spaces as they are IDE default (android studio) and using tabs would make collaboration difficult