There are many discussions about what the maximum line length should be (80, 100, 132 are all popular).
But this all assumes there needs to be a maximum line length at all.
I can see why many people don't like horizontal scrolling. But why not let the editor do the line wrapping?
I can see two options:
The advantage of letting the editor do the wrapping seems obvious: people can use whatever line length they like (even switching to shorter lines in diff-mode or something).
-I use (for the most part) a 76 character line for code blocks, but when working in HTML I do NOT force word-wraps on paragraph content / flow text.
This mix and match when done consistently makes it easier to find your block level openings and closures, reducing the chance of making mistakes.
The choice of 76 charactes is common for 80 character disply because:
1) Some editors add line-draw characters to pretend there's a window edge, so you subtract 2.
2) Then you have the scrollbar to subtract 1 more
3) Any good engineer is a wee bit conservative so you subtract an extra 1 for good measure. (such a safety margin is called "Mr. Scott'ing")
Another reason is that not all terminal/shell editors even provide wordwrapping, at least not in an easily controllable fashion. This can be exacerbated even further
I'll often hear people say "but I have a widescreen that can display 200 or more characters, so what's it matter" -- typically such folks derp along with all their editor windows open maximized using some garbage tabbed editor, something I personally consider a colossal step backwards in functionality! Yes, that's right, I think tabbed editors are garbage.
When working in HTML, CSS, and JavaScript it is often EXTREMELY useful to have them open side-by-side-by-side in separate windows, or even spanning multiple displays. This is something that tabbed editors crapping the code into a single window often fail miserably at. On my 28" 2560x1440 primary display I regularly have a PHP file (which also has my markup) or HTML next to the CSS and JavaScript each taking up a third of the display horizontally... with the larger font size I prefer this works out to leaving around 77 to 78 characters free on each editor window after window chrome is accounted for.
Manually inserting line-breaks and tabs often just results in more legible and easier to follow code. Like with long IF statements word-wrapping just gets hard to follow. The same can often be said of debugging where it's a lot easier to find "line 128" than it is to find "line 60 character 1802".
I mean what's going to be easier to follow or debug?
if ((_.Node.mask(element, nodeMask) && !callback(element)) || (element.firstChild && !_.Node.eachAll(element, callback, nodeMask))) return false;
or:
if (
(
_.Node.mask(element, nodeMask) &&
!callback(element)
) || (
element.firstChild &&
!_.Node.eachAll(element, callback, nodeMask)
)
) return false;
My money is on the latter.
Similarly related is the derpitude of putting attribute/value pairs onto single lines in CSS... making it difficult to tell properties FROM their values at a glance. THIS:
h1 a { display:block; padding:0.4em 0.33em 0.45em 0; letter-spacing:1px; text-decoration:none; color:#FFF; text-shadow: 0 0 2px #FFF, 0 0 0.2em #000, 0.05em 0.05em 0.1em #000, 0.1em 0.1em 0.2em rgba(0,0,0,0.5); }
Is outright idiotic compared to this:
h1 a {
display:block;
padding:0.4em 0.33em 0.45em 0;
letter-spacing:1px;
text-decoration:none;
color:#FFF;
text-shadow:
0 0 2px #FFF,
0 0 0.2em #000,
0.05em 0.05em 0.1em #000,
0.1em 0.1em 0.2em rgba(0,0,0,0.5);
}
It's just easier to follow. Good formatting habits results in easier to digest, easier to debug, and easier to maintain codebases. ANYONE telling you otherwise probably isn't qualified to write a single blasted line of code!
It is just one of the many concepts I had drilled into me when I started programming four decades ago.
That last one having a modern equivalent in web development; This is the Internet, the only thing you can know for certain about a website is that you cannot be certain who is going to visit your website...
Here is a short conversation @airbnb github.com/airbnb/javascript/issues/964
Seems like it boils down to not line length but reading lines that have so much going on.
As for soft wrapping, I guess soft-wrapping + indentation can be challenging.
For me these are the reasons I prefer to have a maximum line length and no wrapping at all: