Characters per line explained

In typography and computing, characters per line (CPL) or terminal width refers to the maximal number of monospaced characters that may appear on a single line. It is similar to line length in typesetting.

History

The limit of the line length in 70–80 characters may well have originated from various technical limitations of various equipment. The American teletypewriters could type only 72 CPL, while the British ones even less, 70 CPL.[1] In the era of typewriters, most designs of the typewriter carriage were limited to 80–90 CPL. Standard paper sizes, such as the international standard A4, also impose limitations on line length: using the US standard Letter paper size (8.5×11"), it is only possible to print a maximum of 85 or 102 characters (with the font size either 10 or 12 characters per inch) without margins on the typewriter. With various margins – usually from 1- for each side, but there is no strict standard – these numbers may shrink to 55–78 CPL.

In computer technology, a line of an IBM punched card consisted of 80 characters. Widespread computer terminals such as DEC's VT52 and VT100 mostly followed this standard, showing 80 CPL and 24 lines. This line length was carried over into the original 80×25 text mode of the IBM PC, along with its clones and successors. To this day, virtual terminals most often display 80×24 characters.

The "long" line of 132 CPL comes from mainframes' line printers.[2] [3] [4] However, some printers or printing terminals could print as many as 216 CPL, given certain extra-wide paper sizes and/or extra-narrow font sizes.[5]

In modern computing

With the advent of desktop computing and publishing, and technologies such as TrueType used in word processing and web browsing, a uniform CPL has been made mostly obsolete. HTML (and some other modern text presentation formats) uses dynamic word wrapping which is more flexible than characters per line restriction and may produce a text block with non-rectangular shape, just like in paper typesetting.

Many plain text documents still conform to 72 CPL out of tradition (e.g.,).

In programming

Many style guides for computer programming define the maximum or desirable number of characters in a line of source code:

Characters per line Programming style
72 Ada[6]

Agda[7]

79 Python[8] [9]
80
88Python, The Black code style[10]
90 CCM4[11]
100 Android[12]

Common Lisp[13] [14]

Google Java[15]

Rust (rustfmt default)[16]

102 Racket[17]
120 PHP
132 Fortran[18] (until 2023)

Blink[19]

Moodle[20]

140Puppet[21]
180 Mono[22]
undefined Go[23]

JavaScript (JavaScript has no official style guide)

With the increasing common use of larger widescreen monitors, some of these limits have been relaxed, as in the Linux kernel[24] and FreeBSD.[25]

See also

Notes and References

  1. Book: Department of the Army. Teletypewriter Circuits and Equipment (fundamentals). 1947. US Government Printing Office. Washington. 69.
  2. Book: Pomerantz. Ori. Vander Weele. Barbara. Nelson. Mark. 3 . Hahn. Tim. Mainframe Basics for Security Professionals. 2008. IBM Press . 9780132704342.
  3. Book: Wells. April J.. Oracle 11i E-Business Suite from the Front Lines. 2003. 168. CRC Press . 9780203508961.
  4. Web site: Difference between..LRECL = 133 and LRECL = 132. IBMMAINFRAMES.com - IBM Mainframe Support Forums. 2004.
  5. Book: Terminals & Printers Handbook 1983–84. Appendix K. Traditional Terminals and Printers. https://vt100.net/docs/tp83/appendixk.html. 1983. Digital.
  6. http://www.adaic.org/resources/add_content/docs/95style/html/sec_2/2-1-9.html Ada 95 Quality and Style Guide
  7. https://github.com/agda/agda-stdlib/blob/master/notes/style-guide.md#other agda/agda-stdlib: Style guide for the standard library
  8. https://www.python.org/dev/peps/pep-0008/#maximum-line-length PEP 8 Style Guide for Python Code
  9. http://pep8.org/#maximum-line-length Style Guide for Python Code
  10. Web site: The Black code style - Black (stable) documentation . 2024-06-28 . black.readthedocs.io.
  11. http://www.cgd.ucar.edu/cms/ccm4/codingstandard.shtml CCM4 self-imposed limit
  12. https://source.android.com/source/code-style.html#limit-line-length Android Code Style Guidelines for Contributors
  13. http://lisp-lang.org/style-guide/#line-length Common Lisp Style Guide
  14. https://google.github.io/styleguide/lispguide.xml#Line_length Google Common Lisp Style Guide
  15. https://google.github.io/styleguide/javaguide.html#s4.4-column-limit Google Java Style
  16. https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#max_width rustfmt Documentation
  17. https://docs.racket-lang.org/style/Textual_Matters.html#%28part._.Line_.Width%29 How to Program Racket: a Style Guide
  18. http://web.ics.purdue.edu/~aai/fortref/html/xlf/xlflrm21.htm#HDRF90FREE FORTRAN 90
  19. https://www.chromium.org/blink/coding-style#TOC-Python Blink Coding Style Guidelines
  20. https://docs.moodle.org/dev/Coding_style#Maximum_Line_Length Moodle Coding Style
  21. Web site: Leach . Parker . The Puppet language style guide . 2024-06-28 . puppet.com . en.
  22. http://www.mono-project.com/community/contributing/coding-guidelines/#line-length-and-alignment Mono Coding Guidelines
  23. https://golang.org/doc/effective_go.html#formatting Effective Go
  24. Web site: The Linux Kernel Deprecates The 80 Character Line Coding Style . 2024-05-31 . www.phoronix.com . en.
  25. Web site: ⚙ D30255 style: Relax 80 column rule . 2024-05-31 . reviews.freebsd.org.