Live data from Hacker News

Why is 80 characters the 'standard' limit for code width?

programmers.stackexchange.com

1–10 of 46 posts

Re: Why is 80 characters the 'standard' limit for code width?

#2
While the initial reason may be historical, I've found that on smaller monitors 80 character width makes it just about wide enough to have two code windows side-by-side. That's why I usually tend to stick to that limit. Though on bigger monitors I often stick to 100.

Re: Why is 80 characters the 'standard' limit for code width?

#3
Back in the day, I used punch cards in college computer courses. Languages like FORTRAN, COBOL, and assembler were column dependent, e.g.

Col. 1 : Blank, or a "C" or "*" for comments Col. 1-5 : Statement label (optional) Col. 6 : Continuation of previous line (optional) Col. 7-72 : Statements Col. 73-80: Sequence number (optional, rarely used today)

With the sequence numbers if you dropped the deck and scrambled the cards, feed the pile through a card sorter machine to put them back in order. If you didn't bother with sequence numbers, another technique was to use a magic marker to draw patterns on the side of the deck to help with resorting it if you dropped it.

Re: Why is 80 characters the 'standard' limit for code width?

#5

While the initial reason may be historical, I've found that on smaller monitors 80 character width makes it just about wide enough to have two code windows side-by-side. That's why I usually tend to stick to that limit. Though on bigger monitors I often stick to 100.

I usually use 100 or 120. It is very useful for having many windows on emacs on a 1920x1080 monitor. Also it is good for github. Anything bigger would need to scroll horizontally for reading the code and that sucks

Re: Why is 80 characters the 'standard' limit for code width?

#7
80 characters is also comfortably within the limits for presenting code in most books, except for pocket reference sized books. The actual limits for most books are about 85 characters, so that leaves some leeway.

Even if I have the screen real estate, I don't think I'd want to intentionally write wide code, and I like self-explanatory names. On a 4k screen I might like Eclipse layouts that put the logging next to the code, rather than have very wide code.

Has anyone created examples of code that gains readability from being wider?

Re: Why is 80 characters the 'standard' limit for code width?

#8
post #4

It's funny to start seeing more and more questions from people who started using computers with Windows 95. Actually, not it's not, little punks making me feel old, get off my lawn.

Because an Emacs window split into two 80x25 frames fits perfectly on a 13" Macbook Air. ;)

Re: Why is 80 characters the 'standard' limit for code width?

#9

While the initial reason may be historical, I've found that on smaller monitors 80 character width makes it just about wide enough to have two code windows side-by-side. That's why I usually tend to stick to that limit. Though on bigger monitors I often stick to 100.

I always thought that it was because you might need to read or edit a file on a dumb terminal while troubleshooting a problematic system (eg, from single user mode or a rescue disk)

Re: Why is 80 characters the 'standard' limit for code width?

#10
IME, there is a very strong correlation between good developers and short lines. Bad devs doesn't mind if some lines are 150+ chars long and require horizontal scrolling. They also don't care that much about consistent naming of symbols or having correctly indented code. There are very strong reasons for keeping your lines short, naming consistent and indentation in check. But at the end of the day, you either "get" it or you don't.
Post reply on HN