Characters per line

From HandWiki
Short description: Max number of monospaced characters allowed on a line

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 ruler on the carriage of an Olivetti Lettera 22. This typewriter can print only 87 characters in a line

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–1.5 inches (25–38 mm) for each side, but there is no strict standard – these numbers may shrink to 55–78 CPL.

Typometer with the characters per line scales
A Fortran coding form (paper). Source code has 72 CPL, but a form is 80-characters wide. Last 8 positions are "identification sequence"

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., RFC 678).

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
90 CCM4[23]
100 Android[24]

Common Lisp[25][26]

Google Java[27]

Rust (rustfmt default)[28]

102 Racket[29]
120 PHP[20]
132 Fortran[30] (until 2023)[31]

Blink[32]

Moodle[33]

180 Mono[34]
undefined Go[35]

JavaScript (JavaScript has no official style guide)

See also

References

  1. Department of the Army, ed (1947). Teletypewriter Circuits and Equipment (fundamentals). Washington: US Government Printing Office. p. 69. https://books.google.com/books?id=itUXAAAAYAAJ&pg=PA69. 
  2. Pomerantz, Ori; Vander Weele, Barbara; Nelson, Mark et al., eds (2008). Mainframe Basics for Security Professionals. ISBN 9780132704342. https://books.google.com/books?id=7e3_IArk9VIC&pg=PT70. 
  3. Wells, April J. (2003). Oracle 11i E-Business Suite from the Front Lines. p. 168. ISBN 9780203508961. https://books.google.com/books?id=q9e3fjChYPYC&pg=PA168. 
  4. "Difference between..LRECL = 133 and LRECL = 132". 2004. http://ibmmainframes.com/post-3565.html. 
  5. "Appendix K. Traditional Terminals and Printers". Terminals & Printers Handbook 1983–84. Digital. 1983. https://vt100.net/docs/tp83/appendixk.html. 
  6. Ada 95 Quality and Style Guide
  7. agda/agda-stdlib: Style guide for the standard library
  8. PEP 8 Style Guide for Python Code
  9. Style Guide for Python Code
  10. GCC Coding Conventions
  11. Google C++ Style Guide
  12. Chromium Objective-C and Objective-C++ style guide
  13. Google Python Style Guide
  14. Google's R Style Guide
  15. Google JavaScript Style Guide
  16. "4.1. Line length". Java Code Conventions. Sun Microsystems, Inc.. 1997. p. 5. http://www.oracle.com/technetwork/java/codeconventions-150003.pdf. 
  17. "Linux kernel code style as of June 2020". https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bdc48fa11e46f867ea4d75fa59ee87a7f48be144. 
  18. "Object Pascal Style Guide". http://edn.embarcadero.com/article/10280#4.4. 
  19. Conway, Damian (2005). Perl Best Practices: Standards and Styles for Developing Maintainable Code. O'Reilly. p. 40. ISBN 978-0-596-55502-3. https://books.google.com/books?id=gJf9tI2mytIC&pg=PT40. 
  20. 20.0 20.1 PSR-2: Coding Style Guide
  21. The Ruby Style Guide
  22. OCaml Programming Guidelines
  23. CCM4 self-imposed limit
  24. Android Code Style Guidelines for Contributors
  25. Common Lisp Style Guide
  26. Google Common Lisp Style Guide
  27. Google Java Style
  28. rustfmt Documentation
  29. How to Program Racket: a Style Guide
  30. FORTRAN 90
  31. Reid, John (2022-03-21), The new features of Fortran 202x, https://wg5-fortran.org/N2151-N2200/N2194.pdf 
  32. Blink Coding Style Guidelines
  33. Moodle Coding Style
  34. Mono Coding Guidelines
  35. Effective Go