4 ms·
Compare this - * Just a few spaces per indent level * To make this work, and yet allow a few indent levels, the code basically have to have small in
by huhtenberg 6y ago
Compare this -
* Just a few spaces per indent level *
To make this work, and yet allow a few indent
levels, the code basically have to have small
indent-levels, so I prefer to have it set to
two spaces per level.
To this, courtesy of the "Linux kernel coding style" [1] -
1) Indentation
Tabs are 8 characters, and thus indentations
are also 8 characters. There are heretic
movements that try to make indentations 4 (or
even 2!) characters deep, and that is akin to
trying to define the value of PI to be 3.
Rationale: [snip]
Now, some people will claim that having 8-
character indentations makes the code move
too far to the right, and makes it hard to
read on a 80-character terminal screen.
The answer to that is that if you need more
than 3 levels of indentation, you’re screwed
anyway, and should fix your program.
Having used 8-char tabs for a very long time, I now find looking at smaller tab'ed code a somewhat unpleasant experience. It feels like the code lacks enunciation. As if it mumbles.
[1] https://github.com/torvalds/linux/blob/master/Documentation/process/coding-style.rst#1-indentation https://github.com/torvalds/linux/blob/master/Documentation/...
- saagarjha 6y agoFixing the width of a tab is akin to trying to define the value of x to be 3.
- huhtenberg 6y agoI have no idea what you mean.
- saagarjha 6y agoset tabsize 4
- huhtenberg 6y agoSure, you can set it to 4 and a properly formatted code will just adjust. That's granted, but irrelevant. The question is in usability of different tab sizes.
- watwut 6y agoThe linux version is overly emotional/rage-y and strongly overstates its cause. The first version is calm and honest, does not pretend preference is actually somehow objective universal statement.
- huhtenberg 6y agoThe latter came from Linus, so yeah it's, erm, opinionated (and what you read as "rage-y" is actually humorous). His point still stands though - if you ever need one too many indent levels, the code could almost certainly use simplification.
- watwut 6y agoIn no way it is like "trying to define the value of PI to be 3". That is just nonsense. > The answer to that is that if you need more than 3 levels of indentation, you’re screwed anyway, and should fix your program. Maybe in context of old C, but in java you have two nestings just for being in class method. So as a general point, it does not stand anyway.
- bzbz 6y agoAnd screens are bigger than they used to be, so you conveniently have more tabs to make up for it. I think it evens out
- watwut 6y agoHow does bigger screen imply that three levels of nesting are bad programming? It just does not.
- bzbz 6y ago> Maybe in context of old C, but in java you have two nestings just for being in class method. So as a general point, it does not stand anyway. In reference to your above point. You’re saying modern Java makes you start out at 2 levels of indentation. I’m saying your modern monitor’s width compensates.
- TrianguloY 6y agoThis comment on a mobile/small screen looks horribly wrong. Exactly like 80-width code on a similar small editor.