
Why is 80 characters the 'standard' limit for code width? - budwin
http://programmers.stackexchange.com/questions/148677/why-is-80-characters-the-standard-limit-for-code-width
======
mhurron
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.

~~~
fredley
Asker of the question here, you are indeed spot on, Windows 95 was the first
OS I used!

The train of reasoning here reminds me of another story (which I think has
been on HN before): Why is a space shuttle engine 4' 8.5" wide?

[http://www.astrodigital.org/space/stshorse.html](http://www.astrodigital.org/space/stshorse.html)

~~~
slavik81
Snopes suggests that story is a little inaccurate:
[http://www.snopes.com/history/american/gauge.asp](http://www.snopes.com/history/american/gauge.asp)

------
cynwoody
Related is the question of why newspapers arrange their text in columns.
According to another stackexchange thread†, studies as far back as the 1880s
indicated that the optimal width for reading prose is 3.5 to 4 inches.

Of course, code isn't prose, but I'm still a fanatic about the 80-character
limit. To assist with keeping lines of code short and sweet, I will often
introduce aptly-named temporary variables and let the compiler sort out what's
actually to happen.

I can easily fit four 80x84 windows on my external monitor (DejaVuSansMono 13
pt).

†[http://graphicdesign.stackexchange.com/questions/3553/why-
do...](http://graphicdesign.stackexchange.com/questions/3553/why-do-
newspapers-use-multiple-columns)

------
Kronopath
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.

~~~
mrweasel
80 or 100 is both fine, but I prefer 80. Shorter lines are simply easier to
read.

It just like reading a text online. Most people would prefer shorter lines,
compared to one extremely long one. It's simply easier to keep track of where
you are.

------
skizm
Java programmers have variables longer than 80 characters now a days.

~~~
67726e
As a primarily Java programmer, those folks need to be drawn and quartered.

~~~
eddieroger
Don't go near Cocoa (/Touch) developers. You will be overtaken by rage.

~~~
skizm
I dabbled in this when I wrote an iOS game for fun. It was pretty surprising
how quickly variable names got out of hand. Random iOS class name:
AVPlayerItemLegibleOutputPushDelegate[0]. Then you try and make instances of
it and you obviously don't want to prefix the class name with something or
risk growing the name even more. And god forbid you try and extend the class
and then make an instance of that using prefixes to indicate more specific
objects.

0 -
[https://developer.apple.com/library/ios/documentation/AVFoun...](https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayerItemLegibleOutputPushDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40013512)

~~~
eddieroger
I've heard stories about one year at WWDC's Stump the Experts, they discussed
the longest method name in ObjC land. I wish I had been there. I also wish I
was going to be there tomorrow, but alas, the marketers and bosses have taken
over.

------
Zigurd
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?

~~~
arrrg
60 to 90 characters per column is widely used in typesetting for good
readability. It’s probably not a good idea to go very far beyond 80 characters
or so purely for readability, no matter the context.

~~~
mantrax5
Well context matters, especially if your language has you starting with at
least two or three tabs for most of your code:

    
    
      package Foo {
          class Bar {
              void baz() {
                  // Most code is nested *at least* this deep.
              }
          }
      }

------
bjourne
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.

~~~
bliker
For me those things are almost like a book cover. If I open a file and I see
freakishly long lines I just _assume_ that the content will be not well
crafted.

------
excitom
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.

~~~
woofyman
I never bothered with sequence numbers. Boy was it a joy to put your card deck
in the reader and wait at the self serve printer, and have your program
compile, run, and produce the correct output the very first time !

------
shmerl
I personally don't like such limit. It's a relic of the old hardware. There is
no need to follow it.

------
DenisM
Old computers (Spectrum, MSX) had 40x25 = 1000 character screens, because
memory was scarce, and 1000 is a nice, round number.

From there, they upgraded to 80x25 (doubling the resolution!). Two things
happened to make it possible: 1) memory got a bit bigger 2) computers started
shipping with dedicated higher-quality monitors (e.g. MSX-2) instead of being
hooked up to TVs, so it was actually possible to read 80 characters on a line,
even though you had to squint a little.

------
raverbashing
Just confirming that 80 characters is an idiotic and arbitrary "standard",
propagated by nothing much more than cargo-culting

"Oh but it fits my screen, fits two-by-two on my screen" change font size,
unless you're using the native 80x25 PC display (some kernel developers use
that)

I can't imagine a worse use of developer time than making everything fit
exactly inside 80 columns

Of course, not having a limit is bad as well, but the main issue is having a
hard limit

~~~
silverlake
I think the rationalizations devs use to defend their arbitrary choices are
fascinating. Readability? My dead-tree Wall Street Journal uses 30 character
width columns. NYTimes online is about 70 chars. New Yorker about 80.
Textbooks, paperbacks, magazines, newsletters... all have different char
widths. Yet I've never suffered an aneurism reading any of these things. The
fact that it doesn't matter much would be sacrilege to most devs.

------
KC8ZKF
Terminals were commonly 80 characters wide, which doesn't explain _anything_.
Why were terminals commonly 80 characters wide? Perhaps terminals were
commonly 80 characters wide because punch cards were commonly 80 characters
wide, which doesn't explain _anything_.

Eighty characters is the "standard" limit for code width because eighty
characters is the "standard" limit for code width.

~~~
wdr1
It doesn't explain _everything_ , but it does explain quite a bit -- notably
it traces the history of the standard back to punchcards.

------
shurcooL
Sure, the number 80 may be rooted in a very old design decision, but that
doesn't mean it's necessarily bad or suboptimal because of that.

More isn't better in this case. When text gets too wide, it becomes harder to
move your gaze from end of one line to beginning of another.

Also, the best number is probably not a hard limit, but a guideline/average to
aim for.

------
analog31
Amusingly, I dismissed the original Apple Mac when it came out, because it
couldn't display 80 columns of readable text.

------
zobzu
120 col 4 space tw real tabs ftw! unfortunately thats sort of flamebait.

------
mantrax5
The most popular text mode on older computers was 80 chars wide. That's really
it. No other reason.

I use 120, plenty of space to fit two code windows side by side and one file
browser.

With HD screens and the verbose languages we use these days (and verbosity is
not always bad), it's a bit silly to try to stick to 80 char cols.

~~~
qbrass
So how much of your code goes past 80 chars? What part of it is taking up the
most space?

Feel free to add any other details, like the kind of programming you do, what
language, etc.

~~~
ndomin
Obj-C / Cocoa uses very long variable names. Someone mentioned this in a post
above with a link for example. It's very hard to stick to < 80.

    
    
                leftWall.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(100, wallHeight)];
    

close to 100 characters.

------
informatimago
The reasons why terminals are 80-character wide are well known and well
documented all over the web. What's sad, is that newbies still have to ask on
stackexchange or Hacker News about it, not knowing how to use a search engine.
What are pupils taught in schools nowadays????

