3 ms·
Optimum for whom? Nineteenth century teletype operators? I never got that argument.
by hoseja 4y ago
Optimum for whom? Nineteenth century teletype operators? I never got that argument.
- goto11 4y agoOptimal for reading prose texts. I believe experiments have shown the optimal line width for reading speed and comprehension to be about 50-60 characters. But as far as I known this have only been researched for reading prose. I doubt the result will translate directly to reading source code, which is read in a completely different way.
- fermigier 4y agoYes, experiments are lacking for code, but I believe the physiological principles (eye fixation, etc) still stand. Also: the optimal line width for prose seems to be 50-75 characters (including whitespace). Source: https://baymard.com/blog/line-length-readability https://baymard.com/blog/line-length-readability Assuming you're using a language where indentation is either mandated (e.g. Python) or recommended (e.g. C with "One True Braces"), with 4-spaces indentation (here again, no experimental evidence, but this seems to be the norm nowadays), and you don't abuse cyclomatic complexity in your functions / methods, you have let's say between 2 and 4 indents on the left so 80 is close to the optimum. Note: up to 100 is probably still OK from a readability POW. But this assumes that all readers are able to increase their window size from the default 80. That's probably true for people using GUIs, but may still be problematic for people with sight issues (e.g. people over 50 or with more serious medical conditions...).
- jstimpfle 4y agos/POW/POV/
- lcnPylGDnU4H9OF 4y agoReminiscent of tabs vs. spaces, this seems to be a new battle in an old war and readability is (allegedly) being held captive by both sides.
- lou1306 4y agoIt's related to how reading and the human eye work. For each eye fixation, you take in about 5-10 characters. The optimal line length for books is about 60-75 characters, which takes somewhere between 6-15 fixation to scan. Code is not like books: most lines will be shorter than the "limit", there's indentation, you're typically reading monospaced characters on a screen, and you have syntax highlighting, etc. So, bumping the length up to 80 characters is still okay, as is the occasional outlier. But regularly writing 100-120 characters-long LoCs will definitely impact readability.