Re:Developers who use spaces make more money than those who ...
by tom_mellior on Thursday June 15, 2017 @12:46PM
(#14562031)
> can make the code a bit less readable
Yes, and I'd say that that's a big problem. I'm not a religious opponent of tabs, but making code less readable just so you can keep using them wouldn't fly if I were Malevolent Whitespace Dictator For Life.
Re:Developers who use spaces make more money than those who ...
by striking on Thursday June 15, 2017 @02:21PM
(#14562968)
IMO, that reads just as well. Each object is still indented, it's close enough.
Re:Developers who use spaces make more money than those who ...
by pera on Thursday June 15, 2017 @01:26PM
(#14562406)
> I'm pretty sure there's a circle of hell specifically for those who mix spaces and tabs.
Could you please clarify why do you consider "tabs for indentation, spaces for alignment" such a bad practice? I have never read any argument against it.
Alignment itself can be done automatically by any editor that supports smart tabs.
Re:Developers who use spaces make more money than those who ...
by lloeki on Thursday June 15, 2017 @05:38PM
(#14564605)
Simple: it's hell to automate.
My process is as follows:
- tabs allow for custom settings
- tabs need spaces to allow for alignment, because previous
- automatically deciding what constitutes alignment vs
indent is a non-trivial problem, highly dependent on the
language†
- using spaces throughout is worse theoretically because
it flattens the theoretical problem but solves impedance
mismatch
- therefore I use spaces and am all the merrier in every practical
use case
- except for languages who make dash 3 easy (such as Go thanks
to gofmt)
- except for projects I have no say in, where I respect the will
of the maintainers, because conventions among well-behaved
people matter more than my highly individual opinion.
† to which the usual answer is "but your editor sucks with lang X", well too bad, I'd rather have pragmatic editor portability than have perfect language parsing in every editor being a pipe dream I hinge upon.
Re:Developers who use spaces make more money than those who ...
by Stratoscope on Thursday June 15, 2017 @03:23PM
(#14563573)
It's not that "tabs for indentation, spaces for alignment" is a bad practice, it's that alignment itself is a bad practice. It doesn't help readability, it directly causes overly long lines of code (which pushes people to try to use narrow indentation to compensate), it's something you have to fiddle with every time you refactor a name, and it gives you spurious changes in your VCS diffs. (Yes, you can set any diff program to ignore whitespace changes, but I want to know when whitespace has changed.)
That being said, this problem and problems like it can be solved simply by not aligning things visually:
Strictly adhering to indentation and never alignment can make the code a bit less readable, but conforming to a canonical indentation like this also makes it easier to reindent, move code around, etc.I think that's what the argument really comes down to – alignment flexibility vs display flexibility. It's interesting to see which people generally prefer.