characters per line

{{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

File:Particolare Olivetti Lettera 22.JPG. 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.{{cite book|editor1-last=Department of the Army|title=Teletypewriter Circuits and Equipment (fundamentals)|date=1947|publisher=US Government Printing Office|location=Washington|page=69|url=https://books.google.com/books?id=itUXAAAAYAAJ&pg=PA69}} 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 {{convert|1|-|1.5|in}} for each side, but there is no strict standard – these numbers may shrink to 55–78 CPL.

File:Typometer 3.jpg with the characters per line scales]]

Image:FortranCodingForm.png 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.{{cite book|editor1-last=Pomerantz|editor1-first=Ori|editor2-last=Vander Weele|editor2-first=Barbara|editor3-last=Nelson|editor3-first=Mark|display-editors = 3 |editor4-last=Hahn|editor4-first=Tim|title=Mainframe Basics for Security Professionals|date=2008|publisher=IBM Press |isbn=9780132704342|url=https://books.google.com/books?id=7e3_IArk9VIC&pg=PT70}}{{cite book|last1=Wells|first1=April J.|title=Oracle 11i E-Business Suite from the Front Lines|date=2003|page=168|publisher=CRC Press |isbn=9780203508961|url=https://books.google.com/books?id=q9e3fjChYPYC&pg=PA168}}{{cite web|title=Difference between..LRECL = 133 and LRECL = 132|url=http://ibmmainframes.com/post-3565.html|website=IBMMAINFRAMES.com - IBM Mainframe Support Forums|date=2004}} 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.{{cite book|title=Terminals & Printers Handbook 1983–84|chapter=Appendix K. Traditional Terminals and Printers|chapter-url=https://vt100.net/docs/tp83/appendixk.html|year=1983|publisher=Digital}}

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

In programming

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

class="wikitable"

! Characters per line

Programming style
72Ada[http://www.adaic.org/resources/add_content/docs/95style/html/sec_2/2-1-9.html Ada 95 Quality and Style Guide]

Agda[https://github.com/agda/agda-stdlib/blob/master/notes/style-guide.md#other agda/agda-stdlib: Style guide for the standard library]

79Python[https://www.python.org/dev/peps/pep-0008/#maximum-line-length PEP 8 Style Guide for Python Code][http://pep8.org/#maximum-line-length Style Guide for Python Code]
80{{columns-list|colwidth=30em|

GNU[https://gcc.gnu.org/codingconventions.html#Line GCC Coding Conventions]

Google

  • C++[https://google.github.io/styleguide/cppguide.html#Line_Length Google C++ Style Guide]
  • Objective-C/C++[https://chromium.googlesource.com/chromium/src/+/master/styleguide/objective-c/objective-c.md Chromium Objective-C and Objective-C++ style guide]
  • Python[https://google.github.io/styleguide/pyguide.html#Line_length Google Python Style Guide]
  • R[https://google.github.io/styleguide/Rguide.xml#linelength Google's R Style Guide]
  • JavaScript[https://google.github.io/styleguide/jsguide.html Google JavaScript Style Guide]

Java{{cite book|title=Java Code Conventions|date=1997|publisher=Sun Microsystems, Inc.|page=5|url=http://www.oracle.com/technetwork/java/codeconventions-150003.pdf|chapter=4.1. Line length}}

Linux kernel{{Cite web|last=|first=|date=|title=Linux kernel code style as of June 2020|url=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bdc48fa11e46f867ea4d75fa59ee87a7f48be144|url-status=live|archive-url=https://web.archive.org/web/20200531215414/https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bdc48fa11e46f867ea4d75fa59ee87a7f48be144 |archive-date=2020-05-31 |access-date=2020-06-13|website=git.kernel.org}} (preferred, not hard requirement)

Object Pascal{{Cite web |url=http://edn.embarcadero.com/article/10280#4.4 |title=Object Pascal Style Guide |access-date=2018-03-14 |archive-date=2015-07-09 |archive-url=https://web.archive.org/web/20150709152411/http://edn.embarcadero.com/article/10280#4.4 |url-status=dead }}

OpenBSD{{Cite web |url=https://man.openbsd.org/style | title=style(9) - OpenBSD manual pages |access-date=2024-03-04 |archive-date=2016-05-24 |archive-url=https://web.archive.org/web/20160524081632/http://man.openbsd.org/style |url-status=live |quote=All code should fit in 80 columns.}}

Perl{{cite book|last=Conway|first=Damian|title=Perl Best Practices: Standards and Styles for Developing Maintainable Code|url=https://books.google.com/books?id=gJf9tI2mytIC&pg=PT40|year=2005|publisher=O'Reilly|isbn=978-0-596-55502-3|page=40}}

PHP[http://www.php-fig.org/psr/psr-2/ PSR-2: Coding Style Guide]

Ruby[https://rubystyle.guide/#80-character-limits The Ruby Style Guide]

OCaml[https://ocaml.org/learn/tutorials/guidelines.html#Width-of-the-page OCaml Programming Guidelines]

}}

88

|Python, The Black code style{{Cite web |title=The Black code style - Black (stable) documentation |url=https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html |access-date=2024-06-28 |website=black.readthedocs.io}}

90CCM4[http://www.cgd.ucar.edu/cms/ccm4/codingstandard.shtml CCM4 self-imposed limit]
100Android[https://source.android.com/source/code-style.html#limit-line-length Android Code Style Guidelines for Contributors]

Common Lisp[http://lisp-lang.org/style-guide/#line-length Common Lisp Style Guide][https://google.github.io/styleguide/lispguide.xml#Line_length Google Common Lisp Style Guide]

Google Java[https://google.github.io/styleguide/javaguide.html#s4.4-column-limit Google Java Style]

Rust (rustfmt default)[https://rust-lang.github.io/rustfmt/?version=v1.5.1&search=#max_width rustfmt Documentation]

102Racket[https://docs.racket-lang.org/style/Textual_Matters.html#%28part._.Line_.Width%29 How to Program Racket: a Style Guide]
120PHP
132Fortran[http://web.ics.purdue.edu/~aai/fortref/html/xlf/xlflrm21.htm#HDRF90FREE FORTRAN 90] (until 2023){{citation |last1=Reid |first1=John |title=The new features of Fortran 202x |date=2022-03-21 |url=https://wg5-fortran.org/N2151-N2200/N2194.pdf}}

Blink[https://www.chromium.org/blink/coding-style#TOC-Python Blink Coding Style Guidelines]

Moodle[https://docs.moodle.org/dev/Coding_style#Maximum_Line_Length Moodle Coding Style]

140

|Puppet{{Cite web |last=Leach |first=Parker |title=The Puppet language style guide |url=https://puppet.com/docs/puppet/8/style_guide.html |access-date=2024-06-28 |website=puppet.com |language=en}}

180Mono[http://www.mono-project.com/community/contributing/coding-guidelines/#line-length-and-alignment Mono Coding Guidelines]
undefinedGo[https://golang.org/doc/effective_go.html#formatting Effective Go]

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{{Cite web |title=The Linux Kernel Deprecates The 80 Character Line Coding Style |url=https://www.phoronix.com/news/Linux-Kernel-Deprecates-80-Col |access-date=2024-05-31 |website=www.phoronix.com |language=en}} and FreeBSD.{{Cite web |title=⚙ D30255 style: Relax 80 column rule |url=https://reviews.freebsd.org/D30255 |access-date=2024-05-31 |website=reviews.freebsd.org}}

See also

References