Vinicius Brasil

November 10, 2022

The sacred 80-column rule

Software engineering sacred texts state code should not run over 80 columns. This rule applies today in many contexts, including Git commit messages and modern code linters. This convention comes from long ago, which is why it may seem strange to wrap code at 80 characters when we have widescreen monitors and high pixel density displays.

Before cassette tapes and floppy disks, data was stored in punched cards. Programmers didn't have monitors neither keyboards, so all code and data input used those punched cards. I, unfortunately, wasn't alive yet to have experienced these golden days of programming.

In 1928, IBM redesigned and patented its own punched card allowing 80 columns per card, doubling its previous capacity. For logistical and physical storage reasons, punched cards were the same size as the 1887 US banknote, 3.25 by 7.375 inches.


Moving a bit forward in time, video terminals (CRTs) in the 1970s replaced paper-based terminals such as the Teletype and DECwriter. Those had printout restrictions that may explain carrying over the 80-column standard - yes, printing code on paper was a thing. CRT terminals such as the DEC's VT52 and VT100 followed IBM's 80-column standard.

vt52.jpg

It's crazy to think this rule is applied to modern linters today, and it's been carried over since punched cards, by cause of the size of US banknotes back in the day. However, we now have evolved to a state where computers don't need a whole room to fit, and we store code in the cloud - wherever that is. Why do we still wrap code at 80 columns?

Traditions tend to follow through unquestioned, but that doesn't mean they are inherently bad. There are reasons to wrap code at a certain limit, for example:

  • Long lines of code are hard to read
  • You can still get multiple editors side-by-side on screen
  • Not everyone uses horizontal screens
  • Displays have grown in time but our eyes haven't

The 80-column hard limit may seem strict for some, but some reasonable limit is nice to have. The Linux kernel recently updated its coding style guide to 100 columns in this commit.

Bonus: Vim and the 80-character limit

I find it useful to have a clear indication of where the limit is in my editor. With the following simple Vim setting, you can have a visual ruler for the columns you want. Vim can also automatically wrap text at column 80. With a visual block selected, just type gq.

" Have a clear indication of the given columns
set colorcolumn=80,100

" Tell vim where you want text to be wrapped
set textwidth=80

About Vinicius Brasil

Building cool stuff with Elixir, OTP and Ruby. Musician and majoring in Theology. I'm based in beautiful Curitiba, and yes, that is my real last name.