3 ms·
In all collaborative projects I've been that allowed tabs, all files that had been edited by tab users were a mishmash of spaces and tabs that made no single ta
by Peaker 9y ago
In all collaborative projects I've been that allowed tabs, all files that had been edited by tab users were a mishmash of spaces and tabs that made no single tab width configuration workable. If you chose tab width as 4, some parts of functions would look right, others would have messed up indentation. Ditto for any other tab size.
The theory of tabs for indent and spaces for alignment works. But when collaborating, the practice requires too much support from tooling and too much education for humans -- so it's just not worth the tiny benefit.
- biggieshellz 9y agoSeems to work OK for the Linux kernel, and the tooling is not onerous -- just run checkpatch.pl on your commits before pushing them upstream.
- user5994461 9y agoThe kernel has an official & mandatory rule to enforce tabs, at a length of exactly 8 spaces per tab. Anything that doesn't respect that will be rejected without mercy.
- Veedrac 9y agoThat's not a fair comparison. You either disallow tabs, or you disallow spaces. A mismatch isn't either, so it doesn't evidence either being better than the other.
- dxhdr 9y agoDisallowing spaces isn't an option, you can't align code using tabs. You have to both disallow spaces and enforce a no-alignment (leading-indent-only) formatting style. Just use spaces! You can't mess it up. ;)
- jimmaswell 9y agoMeticulously lining code up like ASCII art seems like an antipattern to me nowadays. It might make some regions of the code look a little bit nicer, but it's never really strictly necessary and it comes at the cost of higher maintenance - for example, add to that list of assignments with lined up equals signs and you have to make your addition line up too, and if your variable name is longer than the longest one in the list so far you have to move all the previous ones over.
- Veedrac 9y ago> Just use spaces! You can't mess it up. ;) Oh how I envy someone who can say that.
- jimmaswell 9y agoThen just run an autoformatter over the whole codebase once and clean up anything that looks wrong as you come across it later.