Daily Archives: 7/7/2007

Are 80 Columns Enough?

Slashdot asks the question “Are 80 Columns Enough?” Luckily, we have several hundred years of “best practice” in trying to typeset material for maximum legibility to guide us.

Typography guidelines normally limit line lengths to fifty to seventy characters per line, often in narrow columns. The reasons are fairly well understood: your eyes have a fairly narrow range of acute focus (about three inches wide, and having long lines means that you have to have larger amounts of eye motion. You also have a tendency to lose track of where the next line begins when you shift back to the left when lines are long relative to the size of the type you are using.

It is true that most programming languages result in text which is considerably less dense than most prose. It is considered good form to make use of indenting to illustrate the basic blocks of your program, and to break programs into a series of modules which can be fairly easily assimilated by themselves. This by necessity creates a large proportion of white space which one might reasonably deduce softens the effects of long lines, but I know of no research which actually suggests that is true. Anyone?

In the end, I’m guided by a principle that I first heard from Tom Duff: good programs can be read like prose, starting at the top, going to the bottom. Anything which causes you to leap your attention up and down or interrupts your ability to read the code should be viewed as stylistically and structurally questionable. I think that long lines certainly qualify. Often they are used to justify long and confusing combinations of boolean conditions, or to simple cram more operations in a single line. Neither practice enhances legibility, and therefore the reasons for having long lines is on pretty tenuous grounds.

There’s my two cents.

[tags]Rants and Raves,Programming[/tags]