I'm fine with staying under 80 characters per line for code (even if some consider that limit outdated), but I'm split (no pun intended) when it comes to splitting comments over multiple lines, versus writing them on one line (as long as it needs to be) and letting the editors taking care of the wrapping.
I think comments merit a separate discussion given their text (rather than code) nature, with different readability considerations, and a paragraph (rather than line) orientation.
After reading the discussion on comment styles, I've narrowed down my important development flow aspects to the following:
- Using an editor that doesn't support wrapping isn't a problem or excuse. I'm the primary maintainer of the code, with very occasional contributions via GitHub.
emacs
orvi
won't be used. - The code being published on GitHub, should facilitate editing with their editor, which does support soft wraps:
- I get to pick the style, so there's no adherence to an existing style.
Arbitrary line lengths - pros
- searches won't fail just because two consecutive words you happened to search for were arbitrarily separated by
\n *
- excellent screen real estate utilization
Arbitrary line lengths - cons
- with soft wrapping, looks weird in JSDoc:
- really minor, but GitHub's diff mode is "Unified" by default, which displays a horizontal scrollbar. However, if you click "Split", GitHub's diff soft wraps:
- GitHub's viewer does NOT support wrapping, and its width is 128 characters (though some "GitHub wide" user styles exist).
Limited line length pros:
- text is read fastest at 50-75 chars/line, but we're not writing a novel here and if you read the comments, you can afford to spend a few extra seconds
- better display in legacy tools that don't support wrapping
Limited line length cons:
- inserting text in the beginning of a comment while hard wrapping each of its lines can easily cause a cascade of false diffs:
In the wild, I've seen mostly hard wraps (limited line length), despite the diff issue above being rather common and jarring.
What am I missing and how can I make a decision?
Why aren't arbitrarily long lines more commonly encountered in contemporary projects?