Re^2: To <=80 char code line length or not
by hippo (Archbishop) on Jun 08, 2018 at 09:27 UTC
|
I think it's a lucky coincidence that the console width is near the optimal width for eye movement.
I think it's an excellent design choice that the console width is near the optimal width for eye movement.
While it's not a cast-iron rule, I do tend to keep code lines under 80 chars. It's easier to read, easier to debug, prints neatly on pretty much any output device and encourages critical thinking. All IMHO. For collaborative code, perltidy is the winner.
perlcritic (at least version 1.125) seems perfectly happy with absurdly long lines, which is somewhat surprising.
| [reply] |
|
|
Maybe I'm repeating myself, but the problem here is that code is actually a twocolumn format!
(At least mine which IS often documented to the right.)
So it also depends on the documentation style, one can have a 80 column model and reserve comments to separate lines.
edit: I agree about perltidy , which has enough option flexibility to pacify a quarreling team. ;-)
| [reply] |
Re^2: To <=80 char code line length or not
by choroba (Cardinal) on Jun 11, 2018 at 15:36 UTC
|
> Perltidy has very good options to handle most of this
Unfortunately, the devil is in the detail. At work, we tried to run it over our codebase: where the formatting was previously complex and provoked discussions, the automated results were plain wrong, as the meaning of the code was lost.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] |
|
|
| [reply] |
|
|
Exception::throw(
sprintf(
'Problem accessing resource on URI: "%s" by "%s" at "%
+s, line %s".',
$uri, caller()
)
);
was tidied to
Exception::throw(
sprintf(
'Problem accessing resource on URI: "%s" by "%s" at "%s, line %s".',
$uri, caller()
)
);
Basically, long lines are broken in unexpected places, ternary operator is rendered unreadable, etc.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
| [reply] [d/l] [select] |
Re^2: To <=80 char code line length or not
by BrowserUk (Patriarch) on Jun 08, 2018 at 12:10 UTC
|
I think it's a lucky coincidence that the console width is near the optimal width for eye movement... I'm pretty sure this has already been investigated by scientists,
I bet -- in fact I'll pretty much guarantee -- that you cannot cite one authoritative reference for that piece of pseudo-science. (You'll probably claim that you're "too busy", or it's "too hard to do from your phone", like normal.)_
It doesn't even stand up to the most casual of thought processes.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
- 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789 1234 6789
How much wood could Chuck Woods' woodchuck chuck, if Chuck Woods' woodchuck could and would chuck wood? If Chuck Woods' woodchuck could and would chuck wood, how much wood could and would Chuck Woods' woodchuck chuck? Chuck Woods' woodchuck would chuck, he would, as much as he could, and chuck as much wood as any woodchuck would, if a woodchuck could and would chuck wood.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
In the absence of evidence, opinion is indistinguishable from prejudice.
Suck that fhit
| [reply] |
|
|
Surprisingly spurious rebuttal. I was a typographer before I was a programmer and agree with Line length. I checked about a dozen other resources and found *only* agreement with, or within the bounds of, 45 to 75 characters as optimal reading length. Add in the need for extra spacing and punctuation in programming, you get close enough to 80.
| [reply] |
|
|
I was a typographer
And I was a fireman. What of it? Because that occupation is equally (ir)relevant to this discussion.
Source code is not prose, or poetry or a novel. No one needs to (nor should!) speed-read source code. Even with prose, a 45/50 character wide column is painful to read. (Tell me you find it comfortable to read this.)
Source code is an entirely different kettle of fish: tokens + structure. And formating source code according to typographical (paper) rules -- which have been comprehensively demonstrated to make little sense when applied to a VDU (by Northern Telecom amongst others as far back as the early to mid-80s) -- is as inane as white on black themes because there seen as retro and thus 'cool'.
For the most part, code only gets wide when indented and the part of the lines you read are only 50-60 chars anyway; but scrunching those 50-60 characters across three 20 character lines, because the current indent level takes you half way across to the arbitrary limit makes the code less readable, not more so.
And no, moving the nested levels out to a separate, called-once sub does not always make sense, especially if it obscures the structure of the algorithm -- which such artificial re-structuring invariably does.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
In the absence of evidence, opinion is indistinguishable from prejudice.
Suck that fhit
| [reply] |
|
|
> that you cannot cite one authoritative reference for that piece of pseudo-science.
Well please define "authoritative reference", psychologists will normally argue from study to study about methodology and sample. (for instance I'm dyslexic and color blind, did they cover my group in their sample?)
Anyway ...
I was referring from memory (I earned my first money hacking for a DTP product) about what I read about typographical Line_length which is at least normatively set to between 45 and 75 characters.
Normative means we got used to it, like we got used to a decimal system, which is not necessarily the objective best of all parallel universes.
Additionally there are subjective preferences:
60% of respondents indicated a preference for either the shortest (35 CPL) or longest (95 CPL) lines used in the study. At the same time, 100% of respondents selected either one of these quantities as being the least desirable *
Which seems to indicate that around middle you'll have the least discussions with annoyed users.
Anyway all these studies deal - like I said - with prose in paragraphs, not intended code, and I said I'm not dogmatic here.
Code is actually two column text, because comments are best aligned
Regarding your question: So the above WP article lists some studies, do I need to copy&paste them and are they "authoritative" enough? ²
Question: what is the blind text in different sizes supposed to tell us???
*) Hmm ... wondering what dyslexic guys prefer...
²) NB: the German WP article highlights the importance of line spacing while the English strangely doesn't seem to mention it.
| [reply] |
|
|
| [reply] |
|
|
|
|
|
|
In short: Source code is not prose; and typographical rules applied to prose on paper make no sense on screens. (Tell me you find this readable.)
Question: what is the blind text in different sizes supposed to tell us???
It simply demonstrates that blindly saying "the console width is near the optimal width for eye movement" makes no sense, as it doesn't take font size, proportionality, kerning, or the particular users optimal eye-to-screen distance into account.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
In the absence of evidence, opinion is indistinguishable from prejudice.
Suck that fhit
| [reply] |
|
|
|
|