Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is 80 characters the "standard" limit for code width? Why 80 and not 79, 81 or 100? What is the origin of this particular value?

share|improve this question
Argh! Couldn't you have waited a week before asking? This could have been a contest winning question. – Yannis May 15 '12 at 19:44
Before anyone thinks of adding another answer to this question please read the accepted answer and Mark Booth's answer. These answer the question comprehensively. The punchcard came first. – ChrisF May 15 '12 at 20:54
Why this piece of marginal trivia has 139 upvotes is beyond me. Meanwhile, almost every other question (good or bad) in the front page has way less votes. Is our collective voting criteria so broken? :( (@fredley This isn't criticism of you, but of our community) – Andres F. May 24 '12 at 12:26
@AndresF. The reason this post has done well is that it's something a lot of people will be interested in, behind a good title. It spent a day at the top of the supercollider, and made it to Hacker News etc. It may be marginal trivia, but it's good content! – fredley May 24 '12 at 12:56
up vote 547 down vote accepted

You can thank the IBM punch card for this limit - it had 80 columns:

IBM punch card

share|improve this answer
After that early teletypes, and later video terminals used 80 columns (and then 132 columns) as a standard width. – LapTop006 May 15 '12 at 11:43
Now the question is: Why did the IBM punch card have 80 columns? – Factor Mystic May 15 '12 at 14:23
@FactorMystic - the punch card size was based on the size of the currency back in the late 1880's's when Hollerith designed them to assist with the 1890's census. – user54095 May 15 '12 at 14:51
The cards are that size because in 1890, CTR wanted to reuse currency carriers (the dollar was bigger back then) to carry the census data cards. – Al Biglan May 15 '12 at 17:30
@AlBiglan Why was currency that size? – fredley May 15 '12 at 23:13
up vote 162 down vote

As oded mentioned, this common coding standard is a result of the IBM's 1928 80 column punched card format, since many coding standards date back to a time when programs were written on punch cards, one card/line at a time, and even the transition to wider screens didn't alter the fact that code gets harder to read the wider it becomes.

From the wikipedia page on punched cards:

Cultural Impact

  • A legacy of the 80 column punched card format is that a display of 80 characters per row was a common choice in the design of character-based terminals. As of November 2011 some character interface defaults, such as the command prompt window's width in Microsoft Windows, remain set at 80 columns and some file formats, such as FITS, still use 80-character card images.

Now the question is, why did IBM chose 80 column cards in 1928, when Herman Hollerith had previously used 24 and 45 column cards?

Although I can't find a definitive answer, I suspect that the choice was based on the typical number of characters per line of typewriters of the time.

Most of the historical typewriters I've seen had a platen width of around 9 inches, which corresponds with the standardisation of paper sizes to around 8"-8.5" wide (see Why is the standard paper size in the U.S. 8 ½" x 11"? and the History of ISO216 A series paper standard).

Add a typical typewriter pitch of 10-12 characters per inch and that would lead to documents with widths of between 72 and 90 characters, depending on the size of the margins.

As such, 80 characters per line would have represented a good compromise between hole pitch (small rectangular vs. larger round holes) and line length, while maintaining the same card size.

Incidentally, not everywhere specifies an 80 character line width in their coding standards. Where I work has a 132 character limit, which corresponds to the width of typical wide line printers of yore, a 12pt landscape A4 printout and the typical line width remaining in an editor window of Eclipse (maximised on a 1920x1200 screen) after Package Explorer and Outline views are taken into account.

Even so, I still prefer 80 character wide code as it it makes it easier to compare three revisions of a file side-by-side without either scrolling sideways (always bad) or wrapping lines (which destroys code formatting). With 80 character wide code, you only need a 240 character wide screen (1920 pixels at 8 pixels per character) to see a full three-way-merge (common ancestor, local branch and remote branch) comfortably on one screen.

share|improve this answer
Not to start another speculation-fest, but Hollerith's cards had circular holes, not the rectangles of the IBM 5081 et al. And IBM's later foray into cards, the System/3 format, had 96 circular holes in 3 horizontal bands of columns. – Ross Patterson May 15 '12 at 17:44
+1 for looking behind the rather superficial punch card response. – nem75 May 24 '12 at 11:33
A good reason to try to continue using 80 characters even on larger screens is that many programmers prefer to use smaller terminal (or even IDE) windows, rather than having to keep them full-screen at all times. – rkulla Jan 3 '13 at 17:34
@Basic there is an argument that if you can't work within an 80 character line limit then either your identifiers are excessively verbose or you are trying to do too much on one line. Most people are more comfortable with narrower columns of more lines than very long lines, since our eyes and brains have been trained for years through books, newspapers and column width constrained web pages (like this one) which mean that we find it hard to scan and comprehend very long lines. – Mark Booth Apr 30 '13 at 16:46
@MarkBooth I won't drag it out too much as it's a bit of a religious issue but one that gets flagged by PEP8 for being too long is ... ` (8 spaces) return HttpResponse(JsonLib().encode(Ret), content_type="application/json")` and yes it could be broken into multiple lines but it's scattered throughout various controllers and doesn't seem like it's worth splitting up except for meeting the 80-char "standard". – Basic Apr 30 '13 at 17:05

I'd say that's also because old terminals were (mostly) 80x24 characters in size: Back in the days of 80x24 terminals...


To answer more precisely and more thoroughly to the question, 80 characters is the current "universally accepted" limit to code width inside editors because 80x24 and 80x25 formats were the most common screen modes in early I/O terminals and personal computers (VT52 - thanks to Sandman4).

This limit is still valid and somehow important IMHO for two main reasons: the default geometry that many Linux distros assign to newly spawned terminal windows is still 80x24 and many people use them as-is, without resizing. Moreover, kernel, real-time and embedded programmers often work in a "headless" environment without any window manager. Again, the default screen resolution is often 80x24 (or 80x25), and, in these situations, it may even be difficult to change this default setting.

So if you are a kernel, real-time or embedded programmer you should force yourself to respect this limit, just to be a little more "friendly" towards any programmer that should read your code.

share|improve this answer
But old terminals were 80 characters wide because of – Oded May 15 '12 at 14:33
-1 for not reading prior answer and for useless link that says just "Back in the days of 80x24 terminals, one of the original authors of a popular unix game was often complimented on how well his code was commented. He said that he had to do that because he always smoked pot when he coded and would lose his train of thought when the screen scrolled." – gnat May 15 '12 at 14:40
Sorry for the welcome Avio, you just happened to jump in on a post that's got extremely popular! We do things a little differently from the rest of the internet around here. We hate duplication, amongst other things. Take a read of the faq to get started, hope to see you again! – fredley May 15 '12 at 14:51
+1 to justify for downvote. Another +1 (if I could) because 80-character limit for code is because of 80-column terminal and that in turn may or may not be related to punchcards. – Sandman4 May 15 '12 at 15:00
I admit I didn't read the faq first, my fault. I'll do that as soon as possible. As a matter of fact I read the first answer and, in my humble opinion, my answer is (at least cronologically) more relevant than the one on punchcards. I say that because even now, if you open a terminal, it should be 80x24 characters in size. If this, in turn, comes from punchcards I don't know, but what I'm sure of is that, for example editing pieces of linux kernel, you'd better not to write past the 80 chars to be "friendly" even with those who must use VI inside a bare TTY. – Avio May 15 '12 at 15:12

While probably not the original reason for the 80 character limit, a reason that it was accepted widely is simply reading ergonomics:

  • If lines are too short, text becomes hard to read because you must constantly jump from one line to the next while reading.
  • If lines are too long, the line jumping becomes too hard because you "lose the line" while going back to the start of the next line (this can be mitigated by having a bigger inter-line spacing, but this also wastes space).

This is widely known and accepted in typography. The standard recommendation (for text in books etc.) is to use something in the region of 40-90 characters per line, and ideally about 60 (see e.g. Wikipedia, Markus Itkonen: Typography and readability ).

If you aim for 60 characters per line, your upper limit must obviously be a bit higher to accommodate the occasional long expression (and things like margins markers and line numbers), so having an upper limit of 70-80 makes sense.

This probably explains why the 80 character limit was taken over by many other systems.

share|improve this answer

A related question is "why has 80 column persisted". Even the responses on this page are approximately that width. I agree with the historical reasons for 80 columns, but the question is why the standard has persisted. I would claim readability - for prose and code. Our minds can only absorb so much information in one piece. I still use the 80 column marker in my code editor to remind me when a statement is getting too long and obscure. It also leaves me plenty of screen real-estate for the browser, and the supporting IDE windows. Long live 80 column - as a guide not a rule.

share|improve this answer
I've seen the 80-character (approximately) max width mentioned in typography discussions -- apparently it really does help readability, monospace or not. – nkorth Aug 13 '12 at 1:40

Another common line length limit in the days of fixed pitch fonts was 72 characters. Examples: Fortran code, mail, news.

One reason was that columns 73-80 of a punch card were often reserved for a serial number. Why a serial number? If you dropped a card deck, you could pick the cards up in any order, line up the upper left corners (which always had a diagonal cut) and use a card sorting machine to get them back in order.

Another reason for the 72-character limit was that common fonts were 10 points high and 6 points (1/12") wide. An A4 or 8.5" wide page could hold 72 characters in a 6" wide column and still have room for margins of over an inch.

share|improve this answer

I personally stick to "about column 80" for my end of line because further than that causes wrapping or lost code when you print it.

There's punch card legacy as well, but I don't think laser printers or 8.5x11 inch paper was set to conform to punch card limitations.

share|improve this answer
As I suggest in my answer @CMike, I do think that it is possible that the punch card width is related to the size of typewriter platens and thus paper sizes (or vice versa). – Mark Booth Mar 31 '14 at 23:02

Scroll in printers papers were Letters size or 15" wide.

It were the 80 cps line printers for hardcopying of codes or reports, and later on Epson supports 132 cps condensed printing (escape code \015 for condensed print).

share|improve this answer
-1 for not knowing that 80-character printers owe their size to 80 columns punched cards – Ross Patterson May 15 '12 at 17:31
@Ross: you should not downvote anybody for not knowing something on Q&A site! – abatishchev May 15 '12 at 18:30
@abatishchev - but the answer being referred to is on this page. – ChrisF May 15 '12 at 20:35
@abatishchev Actually, that's exactly the idea of StackExchange sites. "Good" answers should be upvoted, and "bad" answers should be downvoted, to ensure that future readers who may not be able to judge for themselves can know the community's opinion of the answers. – Ross Patterson May 15 '12 at 22:54
@abatishchev It isn't about voting down answers you don't like, it's about voting down answers which aren't useful. See the mouse-over text of the voting buttons. – Mark Booth Mar 31 '14 at 23:04

One of the reasons for the 80 column cards may be associated with the 'hand punch' which was probably in use before the electronic card punch machines. It is one which I used in the early 70s on an ICL System 4-50 main frame computer site. One had to punch a section of three? punch knives in the carriage at the same time.

share|improve this answer

protected by gnat Apr 10 '14 at 17:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.