4 ms·
"Tabs are preferred" Aaaarggghh!!! :)
by anentropic 10y ago
"Tabs are preferred"
Aaaarggghh!!!
:)
- Stratoscope 10y agoTabs make great sense in an indentation-based language. One tab, one indent level. Left and right cursor keys move one indent. No questions of how many spaces to use, and no off-by-one errors in your spacing. The only real advantage of indenting with spaces is if you use a column aligned coding style like this: SomeFunctionName(firstArgument, secondArgument, AnotherFunctionHere(itsArgument, itsOtherArgument), lastArgument); If you use tabs for indentation, you're into the old problem of "should I use tabs to indent and spaces to align?" But this kind of column alignment has many disadvantages: excessive line lengths, spurious diffs in your source control when you change the length of a name and have to realign everything, and the fact that you'll very likely forget to realign something when you do a global replace. I've seen each of these problems in the Servo source code which uses mandatory column alignment (examples in one of the links below). An alternative way to format code is to use indentation only with no column alignment: SomeFunctionName( firstArgument, secondArgument, AnotherFunctionHere( itsArgument, itsOtherArgument ), lastArgument ); This solves all of the problems mentioned above, and it means that tabs become a perfectly reasonable way to indent the code, since there's no question of indentation vs. alignment. Here are a couple of previous comments with more examples and discussion of the advantages and disadvantages of indentation vs. column alignment: https://news.ycombinator.com/item?id=10206860 https://news.ycombinator.com/item?id=10206860 https://news.ycombinator.com/item?id=9469713 https://news.ycombinator.com/item?id=9469713
- nilliams 10y agoCouldn't agree more, this is one thing that Python/PEP8 got completely wrong. (Leading) column-aligned code falls down more-often-than-not in practice and is a terrible reason to sacrifice tabs. Tabs are superior. [0] [0] http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/ http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/