3 ms·
The implication in the article and your comment is that tabs let you switch indentation level without any negative consequences. But that’s clearly false. A lo
by audunw 3y ago
The implication in the article and your comment is that tabs let you switch indentation level without any negative consequences. But that’s clearly false.
A lot of code will use space to align code over multiple lines. If you only use tabs, the alignment will be broken in other developers editors if they don’t have the same tab indentation.
The author complains about visual noise with 2 level indentation. But misaligned code can become a complete unreadable mess. You end up being forced to set your tab indentation to the same value as the original author anyway.
So the logical conclusion then may be to use tabs for indentation and spaces for alignment. That would work in theory, but handling that correctly in an editor is nearly impossible.
So then you end up with the conclusion that spaces is the only way that doesn’t have any serious downsides. It’s far from ideal, but i don’t think the purported benefits that tabs have of letting you change indentation later works in practice anyway.
I’ve experienced this personally in a huge code base with multiple authors where some earlier code used tabs. It was always a 50% chance that code with tabs looked like hot garbage as the author had a different tab level than yours. After enforcing using only spaces, at least the code looks fairly organised most of the time.
- redhale 3y agoI don't understand what you mean. Is this an IDE thing? Do you mean the IDE/editor is auto-wrapping long lines (visually)? If not, why would manually indented lines not also use tabs if tabs were the standard?