80 seems to be the default in many different environments and I\'m looking for a technical or historical reason. It is common knowledge that lines of code shouldn\'t exceed 80 c
Your computer probably doesn't have a punch card reader, but it probably does have lpr(1)
which follows the convention set by IBM for punch cards. The lpr(1)
command defaults to Courier font with margins set for 80-columns and 8-space tabs for plain text files on 8.5"x11" paper. Try cat foo.c | lpr
and if the author of foo.c
used conventional line width and source code formatting rules, then the printed page will look mostly readable. Otherwise, best not to kill the trees.
It is because IBM punch cards were 80 characters wide.
As per Wikipedia:
80 chars per line is historically descended from punched cards and later broadly used in monitor text mode
source: http://en.wikipedia.org/wiki/Characters_per_line
Shall I still use 80 CPL?
Many developers argue to use 80 CPL even if you could use more. Quoting from: http://richarddingwall.name/2008/05/31/is-the-80-character-line-limit-still-relevant/
Long lines that span too far across the monitor are hard to read. This is typography 101. The shorter your line lengths, the less your eye has to travel to see it.
If your code is narrow enough, you can fit two files on screen, side by side, at the same time. This can be very useful if you’re comparing files, or watching your application run side-by-side with a debugger in real time.
Plus, if you write code 80 columns wide, you can relax knowing that your code will be readable and maintainable on more-or-less any computer in the world.
Another nice side effect is that snippets of narrow code are much easier to embed into documents or blog posts.
As a Vim user, I keep ColorColumn=80
in my ~/.vimrc
. If I remember correctly, Eclipse autoformat CtrlShiftF, breaks lines at 80 chars by default.
If I remember correctly the old dot matrix printers were only able to print 80 characters across. I am pretty sure my old commodore 64 and 128 had the same 80 characters, now that I think about it, I don't think the monitor could display more than 80 characters either
The LA30 was a 30 character/second dot matrix printer introduced in 1970 by Digital Equipment Corporation of Maynard, Massachusetts. It printed 80 columns of uppercase-only 5x7 dot matrix characters across a unique-sized paper.
http://en.wikipedia.org/wiki/Dot_matrix_printer
One of the characteristics of good typography is properly set measure - length of the line of characters.
There is an optimum width for a Measure and that is defined by the amount of characters are in the line. A general good rule of thumb is 2-3 alphabets in length, or 52-78 characters (including spaces).
It simply makes sense to make your text readable.
See Five simple steps to better typography for more info.
possibly due to screen resolution of 640 pixels.. each character is or was 8 pixels wide giving you 640 (80x8)