Take the 2-minute tour ×
User Experience Stack Exchange is a question and answer site for user experience researchers and experts. It's 100% free, no registration required.

Is there is any definitive research that attempts to answer what character counts make the most human readable line lengths for programming code (typically mono-spaced font, high liklihood of small font size) when considering, in particular, the fact that code bases are very often shared amongst many people; and also the unusual way it looks when compared to other forms of text based communication, such as prose or poetry.

share|improve this question
    
if the code is clean (books.google.de/books/about/…) and best practices are followed, it is legible. If it's clean the line length will be short anyway, so I really doubt there're any studies about this topic. Btw: The "default" 80 chars per line is a relic from when monitors didn't have more horizontal space. –  L. Möller Nov 20 '13 at 10:10
    
There will never be any definitive answer. In programming code line length is very much a matter of preference and usually "regulated" by coding standards. Coding standards differ per organisation (sometimes even per team). Legibility can, but is not required to, factor into the chosen maximum line length of the standard. –  Marjan Venema Nov 20 '13 at 10:13
    
@MarjanVenema - Respectfully disagree. Ability to scan long lines degrades as the line grows longer, so there must exist an optimum (not the same for everybody, but that's immaterial). –  Deer Hunter Nov 20 '13 at 12:52
1  
@DeerHunter: Yes, and personal preference would be based on personal optimum, don't you think? Point is, most coding standards choose an arbitrary line length, often 80 or 120, based on the IDE used, or monkey-stair-banana habits, not on any legibility criteria as such. –  Marjan Venema Nov 20 '13 at 13:21
1  
This research suggests readability is determined by more than line length and type size. I'm assuming this questions is using 'legibility' as a synonym for 'readability'. –  user1757436 Nov 20 '13 at 13:55
show 2 more comments

1 Answer

While there's no definitive answer, reading code is still reading just like any other text and some guidelines indicate that 50-75 characters per line is a good number for English.

The cognitive load of code is often far higher per line than it is in English so you probably want to err on the shorter side. I haven't seen any research on the specific column number after which we start to lose focus when reading code, but I imagine it varies significantly based on programming language.

This would be a very interesting research topic.

share|improve this answer
2  
The semantic "density" of a line of code is nowhere near the semantic complexity of a line of English. A better phrase might be the "cognitive load"? –  Joshua Barron Nov 20 '13 at 22:50
    
A single word, especially in higher order programming languages, can imply any completely arbitrary amount of meaning. –  Jeffy Nov 21 '13 at 1:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.