Live data from Hacker News

Is the 80 character line limit still relevant? (2008)

richarddingwall.name

11–20 of 180 posts

Re: Is the 80 character line limit still relevant? (2008)

#11
The penultimate paragraph of the article really shows its age.

  When there are unclear or conflicting rules ... [y]ou can end up with hilarious games like formatting tennis ...
Back then, formatters were rarely used, if at all. The major benefit of tools like gofmt, Prettier, etc. is that a major source of vacuous commits and code review has gone away.

In the case of Prettier, bikeshedding can still happen over the .prettierrc file, but it's not hard to make an argument for using the default configuration.

Formatters are something I miss whenever using languages without a widely-used formatting tool. For instance, in Common Lisp, code formatting is "whatever Emacs does when formatting the whole buffer". Depending on the exact package used (e.g. SLIME or SLY), the results of formatting the whole buffer may differ. Contrast this to languages like Go where there is one tool (gofmt) and it exposes no configuration, so there is no possibility of bikeshedding over code formatting.

Re: Is the 80 character line limit still relevant? (2008)

#15
post #6

One minor advantage which wasn’t so relevant in 2008: 80 character lines are much easier to read on a smartphone. This is especially true for Safari on iOS, which always seems to make bad wrapping / sizing decisions with plain text. ETA: thinking back on it, several years ago I switched from 120 characters to 80 specifically because of this. I don’t have a car, so I read a lot of code on my phone while taking public…

Someone else is going to be weird and want to look this up so I'll save you the trouble. Yes, aithrowawaycomm's claim about line lengths are supported by many, many different sources who recommend a 50 to 80 character line length. https://duckduckgo.com/?q=reading+optimal+line+length IMHO, 80 characters is too narrow, especially with Python, for most coding tasks so I settle more around 100 (+-20) characters. PEP-8 s…

It's worth noting that most of those studies are for body text. To make that more directly applicable we should exclude indentation, but the additional punctuation (especially commas, but unfortunately no parentheses) also affects it.

Shading lines can also improve readability (this is known; the rest of this comment is speculation). It's probably not enough to simply alternating between e.g. white and off-white background, unlike for tables. More likely an alternation between 3 or 4 subtly-different colors is best; maybe these can form a pattern across additional lines (e.g. 121312321). If the difference isn't subtle enough, editing will suffer whenever you break the line count, but for reference only the human eye is pretty good at aligning subtle things. Maybe even an outright paper-texture background image? (This is more often a gimmick, but it can be useful.)

Re: Is the 80 character line limit still relevant? (2008)

#16
post #13

65-80 for readability however once you introduce indentation this naturally increases. I always felt that shorter lines were a good way to encourage less nested code. Alas after all these years the consensus is against me.

i'm with you

Re: Is the 80 character line limit still relevant? (2008)

#17
At home, if I put VS code on my 1080p 24" vertical monitor, I can see about 100 columns (at a reasonable font size, with the VS code sidebar up). I find that to be a little limiting at times but not too bad, and I can close the sidebar to get to 120 columns. Minor issues with horizontal character count are definitely worth it for the massive vertical space though (about 100 lines of code). I've been thinking about replacing it with a 27" 1440p monitor to get a few extra inches of monitor width at about the same pixel density.

Re: Is the 80 character line limit still relevant? (2008)

#18
post #11

The penultimate paragraph of the article really shows its age. When there are unclear or conflicting rules ... [y]ou can end up with hilarious games like formatting tennis ... Back then, formatters were rarely used, if at all. The major benefit of tools like gofmt, Prettier, etc. is that a major source of vacuous commits and code review has gone away. In the case of Prettier, bikeshedding can still happen over the .p…

In new projects I usually add an empty .prettierrc file with a single comment:

  // Empty file. Use default Prettier settings. No rules here.
To make it clear for other people that it was not just a mistake that the formatter was missing its configuration or that no config file existed at all. Useful to deter from adding new rules because someone is capricious about their own preferences...
Post reply on HN