Why I hate TABs in source code

The TAB character means different things to different people, editors, IDEs and printers. In general, none agree. This means that when you come across someone that has planted TABs in the code they don't care that your editor behaves differently to theirs, and they don't care that it doesn't work for you the way it would for them. They know it is the use of the TABs that causes these issues. They just don't care. I firmly believe that TAB characters are placed in source files by anti-social developers.

Here are some other reasons to hate TAB characters:
  • It is impossible to use TABs to line things up when a logical line has been split into several physical lines. This is because the value of the TAB key has no universally agreed value. The lining up is done by column number but it is unknown how many TABs will get you there. Also if the column number is not an exact multiple of the TAB value then the line will wind up containing a mixture of TABs and spaces.
  • Most editors and IDEs assume that the value they pick for the TAB value is correct. They then mix TABs and spaces. This doesn't work because the value of the TAB key has no universally agreed value. Even when one is sensitive to the TAB issue it is very easy for the editor you use to start inserting TABs instead of spaces and for it to mix TABs and spaces. Eclipse seems prone to this. Emacs also does this by default but this cn be turned off.
  • Although there is no universally agreed on value for TAB, a very common value is 8. This is too large for a single indentation level so when someone uses an indent level of 4 and they put TABs in the code they can cause a greater level of indentation for other people, editors, IDEs and printers.
  • The TAB character is like an unexploded landmine. You don't know it's there until you step on it. It is particularly suprising on lines that contain mixtures of TABs and spaces.
  • They cause arguments. Possibly because they means different things to different people, editors, IDEs and printers. In general, none agree, which can cause source to appear to be layed out wrong and for files to get printed with wrong/messy indentation. The arguments quickly reach religious intensity.
One thing I come across that is very common with people that use the TAB character is that they assert that the behaviour they see is completely consistent. They say that the different editors, IDEs, printers etc etc all agree on the value that they use. It is just your editor that is different. No-one else has a problem so the problem must be with you. Don't listen. This is just not true. The fact that your editor shows that the value of TAB is different to their editor just goes to show that different editors treat the TAB character differently. It proves my point. However, all editors treat the space character the same way. You don't get people complaining about the space character being used. See Tabs versus spaces: an eternal holy war for more ranting.