Column Width: What is the One True Way?

Should you limit the width of your source code? You can’t read code
that goes off the edge of your screen. So your font size, resolution
and monitor all combine to produce a point at which you must break (or
at least wrap) your lines of code.

I don’t like wrapping. Lines of arbitrary length that wrap wherever
I happen to have positioned the right-hand side of my window seem

Even if you have plenty of room for more columns, standardising on a smaller number means that when reviewing code
you can see changes side by side using a difference viewer.

Given that I am going to insert a line break somewhere in my code,
where should it go?

There are many possible answers.

COBOL allows approximately 66 characters for code (72 columns – space
for line numbers).

Fortran has 72 usable columns from a maximum of 80.

xterm and gnome-terminal (among others) open 80 columns wide by
default. So does emacs.

vim allows 8 columns for line numbers, leaving 72 usable columns on
a standard terminal.

80 columns was built in to Apple //e motherboard.

Sun’s Code Conventions for the Java Programming Language say:

4.1 Line Length

Avoid lines longer than 80 characters, since they’re not handled well by many terminals and tools.

Note: Examples for use in documentation should have a shorter line length-generally no more than 70 characters.

The linux kernel seems to mostly be broken at 80 columns but there are plenty of exceptions (91-column example):

File: linux/drivers/firmware/efivars.c
Line:  749
printk(KERN_ERR "efivars: Sysfs attribute export failed with error %d. ", error);

Some people definitely go wider than 80 columns.

If you want to be able to “> ” quote in an email on an 80-column terminal without wrapping, you’ll have to limit yourself to 78, or less for nested quoting.

GNUStep coding standards say 80 columns. So do other standards (cites printing as the reason, not screen space).

72 and 80 seem to have originated with punch cards, but are by far the most common standard. So, is 72 or 80 columns old-fashioned? Pointlessly restrictive? Or is it the One True Way? Make a comment and let me know what you think!

3 Replies to “Column Width: What is the One True Way?”

  1. I would like to see IDE’s being smarter about how they wrap code. The alternative, losing over half my screen because one person on the team is using 80-column vi, really sucks.

  2. Whuh? auto-format.

    What I want is a source code repository system that is smart enough to just plain not bother with changes that have no effect at all on the Abstract Syntax Tree representation of the code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.