Skip to main content

Tabs or Spaces?

2 min read

Good coders indent their code, as it makes the whole mess a lot more readable.

There are two ways of doing this, one using tabs, and another using spaces.

Mostly this is down to personal preference, but leads to countless arguments when tabbers and spacers collaborate on a project. Leading to the production of style guides and dissatisfaction all round.

Personally, I'm very much in the tabs camp, because:

  1. They're the semantically correct character to use
  2. They remove ambiguity, i.e. one tab per indent ("Ok, so Fizzbuzz should use spaces, but how many?")
  3. They allow a developer agency within a consistent style - some devs prefer small indents, others with huge screens prefer bigger ones. Tabs let you render your own choice, but preserve a common style.
  4. You only hit one button

Most spacers I've met are so because this was the default in their IDE and they don't like change. Nobody has yet convinced me that spaces for indents is objectively superior to tabs, and my personal view is that they're the coding equivalent of hitting enter a bunch of times in word, when what you actually want is a page break.

But, understanding is important, and I'm prepared to be convinced. So, Spacers... why?

(yes.. I'm aware this is possibly not the most important issue of our age, but I'm genuinely interested...)