TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

61 pointsby budwinalmost 11 years ago

16 comments

mhurronalmost 11 years ago
It&#x27;s funny to start seeing more and more questions from people who started using computers with Windows 95.<p>Actually, not it&#x27;s not, little punks making me feel old, get off my lawn.
评论 #7830655 未加载
评论 #7830441 未加载
评论 #7830534 未加载
评论 #7830610 未加载
评论 #7830519 未加载
cynwoodyalmost 11 years ago
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.<p>Of course, code isn&#x27;t prose, but I&#x27;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&#x27;s actually to happen.<p>I can easily fit four 80x84 windows on my external monitor (DejaVuSansMono 13 pt).<p>†<a href="http://graphicdesign.stackexchange.com/questions/3553/why-do-newspapers-use-multiple-columns" rel="nofollow">http:&#x2F;&#x2F;graphicdesign.stackexchange.com&#x2F;questions&#x2F;3553&#x2F;why-do...</a>
Kronopathalmost 11 years ago
While the initial reason may be historical, I&#x27;ve found that on smaller monitors 80 character width makes it just about wide enough to have two code windows side-by-side. That&#x27;s why I usually tend to stick to that limit. Though on bigger monitors I often stick to 100.
评论 #7830509 未加载
评论 #7830420 未加载
评论 #7830442 未加载
评论 #7830618 未加载
skizmalmost 11 years ago
Java programmers have variables longer than 80 characters now a days.
评论 #7830474 未加载
评论 #7830514 未加载
评论 #7831580 未加载
Zigurdalmost 11 years ago
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.<p>Even if I have the screen real estate, I don&#x27;t think I&#x27;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.<p>Has anyone created examples of code that gains readability from being wider?
评论 #7830459 未加载
bjournealmost 11 years ago
IME, there is a very strong correlation between good developers and short lines. Bad devs doesn&#x27;t mind if some lines are 150+ chars long and require horizontal scrolling. They also don&#x27;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 &quot;get&quot; it or you don&#x27;t.
评论 #7830486 未加载
excitomalmost 11 years ago
Back in the day, I used punch cards in college computer courses. Languages like FORTRAN, COBOL, and assembler were column dependent, e.g.<p>Col. 1 : Blank, or a &quot;C&quot; or &quot;*&quot; 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)<p>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&#x27;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.
评论 #7830454 未加载
raverbashingalmost 11 years ago
Just confirming that 80 characters is an idiotic and arbitrary &quot;standard&quot;, propagated by nothing much more than cargo-culting<p>&quot;Oh but it fits my screen, fits two-by-two on my screen&quot; change font size, unless you&#x27;re using the native 80x25 PC display (some kernel developers use that)<p>I can&#x27;t imagine a worse use of developer time than making everything fit exactly inside 80 columns<p>Of course, not having a limit is bad as well, but the main issue is having a hard limit
评论 #7830955 未加载
评论 #7830982 未加载
shmerlalmost 11 years ago
I personally don&#x27;t like such limit. It&#x27;s a relic of the old hardware. There is no need to follow it.
DenisMalmost 11 years ago
Old computers (Spectrum, MSX) had 40x25 = 1000 character screens, because memory was scarce, and 1000 is a nice, round number.<p>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.
KC8ZKFalmost 11 years ago
Terminals were commonly 80 characters wide, which doesn&#x27;t explain <i>anything</i>. Why were terminals commonly 80 characters wide? Perhaps terminals were commonly 80 characters wide because punch cards were commonly 80 characters wide, which doesn&#x27;t explain <i>anything</i>.<p>Eighty characters is the &quot;standard&quot; limit for code width because eighty characters is the &quot;standard&quot; limit for code width.
评论 #7831043 未加载
shurcooLalmost 11 years ago
Sure, the number 80 may be rooted in a very old design decision, but that doesn&#x27;t mean it&#x27;s necessarily bad or suboptimal because of that.<p>More isn&#x27;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.<p>Also, the best number is probably not a hard limit, but a guideline&#x2F;average to aim for.
analog31almost 11 years ago
Amusingly, I dismissed the original Apple Mac when it came out, because it couldn&#x27;t display 80 columns of readable text.
informatimagoalmost 11 years ago
The reasons why terminals are 80-character wide are well known and well documented all over the web. What&#x27;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????
zobzualmost 11 years ago
120 col 4 space tw real tabs ftw! unfortunately thats sort of flamebait.
mantrax5almost 11 years ago
The most popular text mode on older computers was 80 chars wide. That&#x27;s really it. No other reason.<p>I use 120, plenty of space to fit two code windows side by side and one file browser.<p>With HD screens and the verbose languages we use these days (and verbosity is not always bad), it&#x27;s a bit silly to try to stick to 80 char cols.
评论 #7830642 未加载
评论 #7831071 未加载
评论 #7830850 未加载