Comment by strogonoff

Comment by strogonoff 3 days ago

10 replies

Come for punchcards, stay for legibility.

80 characters per line is an odd convention in the sense that it originated from a technical limitation, but is in fact a rule of thumb perfectly familiar to any typesetting professional from long before personal computing became widespread.

Remember newspapers? Laying the text out in columns[0] is not a random quirk or result of yet another technology limitation. It is the same reason a good blog layout sets a conservative maximum width for when it is read on a landscape oriented screen.

The reason is that when each line is shorter, the entire thing becomes easier to read. Indeed, even accounting for legibility hit caused by hyphenation.

Up to a point, of course. That point may differ depending on the medium and the nature of the material: newspapers, given they deal with solid plain text and have other layout concerns, limit a line to around 50 characters; a book may go up to 80 characters. Given a program is not a relaxed fireside reading, I would place it closer to the former, but there are also factors and conventions that could bring acceptable line length up. For example, indentation and syntax highlighting, or typical identifier length (I’m looking at you, CNLabelContactRelationYoungerCousinMothersSiblingsDaughterOrFathersSistersDaughter), or editor capability to wrap lines nicely[1].

Finally, since the actual technical limitation is gone, it is actually not such a big deal to violate the line length rule on occasion.

[0] Relatedly, codebases roughly following the 80 character line length limitation unlock more interesting columnar layouts in editors and multiplexers.

[1] Isn’t the auto-wrap capability in today’s editors good enough that restricting line length is pointless at the authoring stage? Not really, and (arguably) especially not in case of any language that relies on indentation. Not that it could not be good enough, but considering code becomes increasingly write-only it seems unlikely we will see editors with perfect, context-sensitive, auto-wrap any time soon.

naikrovek 3 days ago

I’m very sure this is a myth. Like any good myth, it makes sense on the surface but holds zero water once you look close.

Code isn’t prose. Code doesn’t always go to the line length limit then wrap, and prose doesn’t need a new line after every sentence. (Don’t nitpick this; you know what I’m saying)

The rules about how code and prose are formatted are different, so how the human brain finds the readability of each is necessarily different.

No code readability studies specifically looking for optimal line length have been done, to my knowledge. It may turn out to be the same as prose, but I doubt it. I think it will be different depending on the language and the size of the keywords in the language and the size of the given codebase. Longer keywords and method/function names will naturally lead to longer comfortable line lengths.

Line length is more about concepts per line, or words per line, than it is characters per line.

The 80-column limit was originally a technical one only. It has remained because of backwards compatibility and tradition.

PaulDavisThe1st 3 days ago

When I read text I prefer it to use the lessons

of typography and not be overly wide, lest my saccadic

motion leads my immersion and comprehension astray.

    However when I read code I do not want to scan downwards to complete the semantics of a given expression because that will also break my comprehension and so when a line of code is long I'd prefer for it to remain long unless there are actually multiple clauses

    and other conditionally chained

    semantic elements

    that are more easily read alone
  • iknowstuff 3 days ago

    oof this looks awful on mobile, with extra line breaks

    • PaulDavisThe1st 3 days ago

      I don't know any way to force line breaks on HN without extra line breaks ... do you?

      • [removed] 2 days ago
        [deleted]
      • [removed] 2 days ago
        [deleted]
Xss3 3 days ago

80 chars per line was invented when languages used shortened commands though. Nowadays 120 is more appropriate. Especially in Powershell. Not so much in bash where commands are short, 80 can stay alive there!

justsomehnguy 2 days ago

> It is the same reason a good blog layout sets a conservative maximum width for when it is read on a landscape oriented screen.

Except 99.9% of times it's becomes 50 characters with 32pt font which occupies ~25% of the horizontal space on a 43".

"Good" my ass.

int_19h 2 days ago

The right answer to this is that IDEs should wrap lines automatically according to the actual dimensions of the editor, but they need to understand the syntax of the language they are wrapping to do that right.

UltraSane 2 days ago

The 80 char max line width convention makes no sense with modern monitor resolutions and ultrawides being very common.