3 ms·
Only works if people use tabs for indentation and spaces for alignment which I've never seen anybody maintain successfully on a big project. The code the parent
by simias 9y ago
Only works if people use tabs for indentation and spaces for alignment which I've never seen anybody maintain successfully on a big project. The code the parent linked is not indentation, it's alignment so it should be formatted using spaces regardless otherwise it breaks that way. If you have to impose tab width to have proper readability then what's the point? Try hacking the linux kernel with tabs != 8 spaces and see how long you last before all the broken alignment drives you crazy.
Furthermore if your coding style imposes some kind of width restriction you also have to commit to a certain tab width anyway.
Beyond that if you really value configurability it's a bit odd to limit yourself to "I want to configure tab width". How about bracket positions, spacing between operators, variable names etc... ? All these seems are arguably more important for readability and code understanding than indentation. Ideally programming languages would be stored as abstract syntax trees that you can display however you like but we're still using dumb all ASCII text files.
In theory tabs are mildly superior to spaces, pragmatically it's spaces all day every day as far as I'm concerned.
- coldtea 9y ago>Only works if people use tabs for indentation and spaces for alignment which I've never seen anybody maintain successfully on a big project. It shouldn't be left to the devs. All languages should have something like Go's gofmt -- or even better, mandatory whitespacing/tabs rules. If you don't respect them (which the auto format tool could help you automatically do), the program shouldn't compile.
- warmwaffles 9y ago> All languages should have something like Go's gofmt -- or even better, mandatory whitespacing/tabs rules. If you don't respect them (which the auto format tool could help you automatically do), the program shouldn't compile. It exists `clang-format`
- coldtea 9y agoFormatters / indent do exist. But they're not widely accepted by most languages devs (like gofmt is by Go programmers), nor is their use enforced by the compiler (even in Go).