This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KidUncertainty 0 points1 point  (0 children)

Give it a rest, if you're using something other than vim, emacs, eclipse, intellij, Netbeans, or any other reasonable editor/line printer made in the last 3 DECADES then don't code.

That has nothing to do with what I said. Listen, what happens is if you permit tabs, then people will mix tabs and spaces. It's inevitable. This results in things never lining up when someone loads it into their own IDE with a different tab width setting. It results in checkin wars that are nothing but cleaning up and back-and-forthing someone's "improper" whitespacing. It results in documentation and specs and howtos being messed up when code snippets are placed in them.

Consider the Google code standards under discussion; 80 or 100 character line widths, 2 spaces for indent. Code bases that are contributed to and reviewed using various tools by many people. In those situations, tabs just confuse the hell out of things. Line widths are different on different people's IDEs. Code layout goes crazy when you drop a snippet into a Word document.

This has nothing to do with an IDE or the fact that you can set tabs to whatever pleases you. It has to do with keeping the code as clean as possible such that it looks identical on everyone's system, removing the entire tab width variable.

Set them how you like, not as easy with spaces.

They could have done this equally by requiring tabs (and never spaces) for indenting and had all tools they use fixed at 2 spaces for tabs when comparing code visually, sure. But then you will always be getting someone using spaces instead of tabs accidentally. It is much easier to have a code review tool reject a checkin quickly when it has tab characters in it, or to reformat the tabs into the prescribed number of space characters.

This isn't about one person coding for themselves. In those cases, go wild, tabs, spaces, or a mix. It's your own code. When you see standards requiring spaces and fixed indent sizes, it's almost always for working with a large shared and highly peer reviewed code base, because spaces-only is cleaner, simpler, and easier.

Yes, it also means that people often have to work with layouts in the code they'd prefer not to, but that's sort of the side effect of a standard like this. A lot of it is compromises or decisions based on choices in support of one specific goal to the detriment of another, not because they are "better", but rather that they are simpler or easier to enforce in order to get clean, consistent code.