Why Tabs > Spaces

Sam Holmes
2 min readFeb 19, 2015

--

The debate among programmers as to whether tabs are better than spaces is an age old conflict. Ultimately, what one chooses is their preference. However, allow me to present my case in hopes to persuade you into choosing tabs over spaces.

It’s simple really. Tabs are better than spaces if you believe that content should be separated from presentation. Much like how a web developer would choose to keep content in HTML markup and presentation in CSS markup, tabs allow one to keep the presentation of indentation separate from the content. How? A tab is a single character, and this single character represents one thing: an indentation. The size of this indentation can be controlled by a good editor (if you use notepad, you’re out of luck; also what’s wrong with you?). If you use spaces, you’re using multiple pieces of information embedded within the content (the file) to tell you not only that there is an indentation, but also how to present that indentation–how to style it. The only way to change the presentation then would be to change the actual contents of the file.

How is that a good thing? It’s not. If a developer likes 4 space indentation and another likes 2 space indentation, their would need to be two versions of the same file in order for both developers to be happy. They couldn’t easily diff the files then without noticing a shit ton of difference in how the indentation is presented. However, if they were using tabs, this would be a different story.

</my case>

--

--