5 ms·
Tabs don't work very well when you use whitespace for alignment, for example in multi-line statements. Change the tab size and it's all off... And seeing as 80
by yAnonymous 10y ago
Tabs don't work very well when you use whitespace for alignment, for example in multi-line statements. Change the tab size and it's all off...
And seeing as 80 characters is still the normal line limit, because of window splitting, it does happen quite often.
- Stratoscope 10y agoThe problem there isn't tabs, it's column alignment. If you stop using alignment and use only indentation for your multiline statements, these issues go away. Your code will be just as readable with any tab size, and even in a proportional font. And your line lengths get much shorter in the process. For specific examples, see the other comments in this thread from scrollaway and myself, in particular the Servo source code I linked to.
- deleted 10y ago[deleted]
- yAnonymous 10y agoSo you're trying to dictate a coding style to make up for tabs' weaknesses? That's like Apple's reaction to bad reception on phones: "You're holding it wrong". No, thanks, I'd rather use spaces that don't require any workarounds.
- Stratoscope 10y ago> So you're trying to dictate a coding style to make up for tabs' weaknesses? Not in the slightest. The disadvantages of column alignment have nothing to do with whether you use tabs or spaces. I don't recall for sure, but I think I was using spaces for indentation at the time that I stopped using column alignment. Column alignment has the same problems if you indent with spaces: it leads to excessive line length, it's unfriendly toward source control diffs, it's fiddly to maintain, it mandates the use of a monospaced font, and I find that it harms readability compared to the alternative of using indentation. Take a look at the Servo code examples I linked to in another comment. Are the column-aligned versions a better way to format code than the indented versions? Here's another way to look at it. If the column-aligned way of writing a multiline function call or expression is such a good thing, why don't we also format blocks of statements this way: if( foo == bar ) { if( baz == moo ) { console.log( "yes" ); this.that = true; } else { console.log( "no" ); this.that = false; } } instead of: if( foo == bar ) { if( baz == moo ) { console.log( "yes" ); this.that = true; } else { console.log( "no" ); this.that = false; } } It is probably obvious that I prefer the latter, as would most developers. So why not apply the same formatting principle to expressions that we apply to statements?
- yAnonymous 10y ago"Many of us" - you are using that way too often in your posts and it's a pseudo argument. Fact is, you're giving up the choice of different coding styles to make something broken work. "Many of us" prefer spaces for that reason and that's why it has become the de facto standard.
- Stratoscope 10y agoYour point about my overuse of "many of us" is a good one, so I changed it to "I" in the comment you just replied to. Fair enough? But look, my real point here is that column alignment is detrimental in several ways, and indentation is a better way to illustrate your code structure - both for statements and expressions. Using indentation instead of column alignment isn't a workaround for anything - it's just a more practical, readable, maintainable way to format your code. This question really has nothing to do with tabs or spaces.
- yAnonymous 10y agoI see the points for VCS and non-monospace fonts, minor as they may be, but readability is absolutely a matter of choice. While we're on the matter of user prefereces and numbers: Most style guides recommend spaces as lined out in my other post. >Google, Microsoft, Apache and NASA for C-family languages, Crockford and almost every other web-related style guide I've ever seen recommend the use of spaces. Apple is a notable exception. That doesn't make them right, but I'd like to know how you came up with the "many of us" in the first place, because there are far more developers who use spaces (https://ukupat.github.io/tabs-or-spaces/ https://ukupat.github.io/tabs-or-spaces/), and it's not even close.
- scrollaway 10y ago"Many of us" doesn't imply "a majority of us". This statement isn't contradictory and is backed up by the data you linked: "Many of us use tabs. Many of us use spaces. Some of us use form-feed.. bloody nutters!"
- 10y ago