Live data from Hacker News

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

programmers.stackexchange.com

21–30 of 46 posts

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

#21
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.

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

#22
post #13

Earlier quoted context omitted.

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

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

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

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

#23
post #12
post #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 th…

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.

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

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

#24
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.

> It's funny to start seeing more and more questions from people who started using computers with Windows 95.

I don't know why they stuck with it!

C64s and amigas.. when computers were cool before microsoft ruined it! Now we've been saved by apple, hurah

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

#25

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.

If I am on 3270 or 5250 I have 80/132 but for the most part even when using the PC based editors we have I find no issues with 80 columns because even on the wide screen monitor I have information panels and such taking up space, plus I can easily side by side code.

I am also of the opinion that like names, when the line gets too long the readability goes out the door

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

#26

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.

100-120 is definitely a lot more comfortable for most situations. It's good to have a width limit, but sticking with 80 for tradition's sake can often be worse than having none at all.

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

#27
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...

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

#28
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.

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

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

#30
post #28
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.

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

Snopes suggests that story is a little inaccurate: http://www.snopes.com/history/american/gauge.asp
Post reply on HN