3 ms·
I'm pretty sure there's a circle of hell specifically for those who mix spaces and tabs. That being said, this problem and problems like it can be solved simpl
by news_to_me 9y ago
I'm pretty sure there's a circle of hell specifically for those who mix spaces and tabs.
That being said, this problem and problems like it can be solved simply by not aligning things visually:
print(
'some long thing',
further,
arguments
)
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.
- tom_mellior 9y ago> 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.
- striking 9y agoIMO, that reads just as well. Each object is still indented, it's close enough.
- pera 9y ago> 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.
- Stratoscope 9y agoIt'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.)
- lloeki 9y agoSimple: 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.