PBP: 011 Tabs

The PBP suggests using spaces to indent all code lines, instead of hard tabs. The hard tab character should appear nowhere in a file.

I disagree with this, but have given up the argument and simply do it anyway. I feel it a minor loss, and not worth the confusion it causes from people who don’t understand hard tabs.

Really, they’re neat. They mean I can tell my editor, “hard tabs are xx wide” and it will keep the indentation right. Nothing but the initial indentation should use hard tabs, so that everything past the indent stays correct.

That’s not what happens, though, so things look dorky if you change the settings, so nobody wants to, so we may as well use spaces.

So, use spaces, and get an editor smart enough to manhandle the code around to where it’s how you want it. It’s just how the world works.

(Except for Makefiles, which still demand hard tabs and screw up virtually everyone who uses them infrequently.)

2 Responses to “PBP: 011 Tabs”

I must respectfully but firmly disagree with your assertion “and get an editor smart enough to manhandle the code around to where it’s how you want it. It’s just how the world works”. It only works if you work in a small team with everyone 100% of time viewing the code in the same editor. Never happens in real world. You view the code diffs for code review? Both “diff” in Unix and Atlassian Crucible will display your hard tabs as incredibly mis-formatted code. Use “vi” or “pico” to quickly scan/edit through code in your terminal? BAM! Your code looks awful.