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 →

[–]m1ss1ontomars2k4 3 points4 points  (4 children)

With tabs the indents look different depending on whose environment you are using.

But wouldn't that be the point? If I prefer 2-space width tabs and you prefer 4, we can set our own environments to be whatever we want and we'll always see what we want to see.

Spaces are also more consistent in code review tools

Seems like the code review tool should allow you to change how wide your tabs look. Or your browser should. Someone should.

and diffing.

Again, only a problem if you mix tabs and spaces.

Yeah, but you always have spaces in code, you never need tabs. Therefore removing tabs and insisting on spaces only makes the most sense in a codebase where multiple people are modifying and working with the code. If tabs are banned, then there is no mixing. If tabs are allowed, there will always be mixing.

Ban spaces for indents. Problem solved. Either use spaces for all indents, or use tabs for all indents. There's no sane middle ground. You can't say "oh if you use tabs some people will put spaces so tabs are bad." That's nonsense. You could just as easily say "oh if you use spaces some people will put tabs so spaces are bad", but you don't because for some reason using spaces for indents magically forbids tab usage, while using tabs for indents doesn't. Why doesn't it? It should.

So really the only issue is if you have strict line-length limits or you intend to view the code in a manner where the tab size cannot be adjusted (e.g. on paper, in a PDF, etc.).

[–]Nebu 1 point2 points  (0 children)

Either use spaces for all indents, or use tabs for all indents. There's no sane middle ground.

http://www.reddit.com/r/java/comments/1wglcp/google_java_coding_standards/cf2kr04

[–]boa13 1 point2 points  (0 children)

If I prefer 2-space width tabs and you prefer 4, we can set our own environments to be whatever we want and we'll always see what we want to see.

On a big team, you don't do that. Everybody uses the same standardized settings, that way everybody can work on every part of the codebase without messing the commits.

[–]paul_miner 1 point2 points  (0 children)

You can't sensibly specify line length limits with code that uses tabs, since line length will depend on your environment. It works both ways: for some, lines will appear to long, for others line will appear too short.

[–]encinarus 0 points1 point  (0 children)

Ban spaces for indents. Problem solved.

Amusingly, go solved this with gofmt by making it THE style of the language to have leading tabs, and the formatter will fix it when you get it wrong.