Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Finding the start of the next line is a challenge universal to both code and prose, and the longer the line the harder it gets, regardless of how good your vision is. I acknowledged that there are other factors with code (such as indentation or syntax highlighting), which is why 80 characters—wider than either newspaper or book—makes sense, unless your typical identifiers are really long.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: