Live data from Hacker News

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

programmers.stackexchange.com

41–46 of 46 posts

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

#41

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.

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.

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

#42
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????

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

#43
post #41

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.

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.

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
            leftWall.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(100, wallHeight)];
close to 100 characters.

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

#44
post #22

Earlier quoted context omitted.

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 prefixe…

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.

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

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

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

#46
post #6

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

Hey, leave those guys alone: It's Objective-C who has the biggest names of them all. It's class names that are huge anyhow in Java. Both are huge in Objective-C (class and variable)

  --Objective-C Dev who sorely wants namespaces
Post reply on HN