When I was a young enlisted Marine, barely out of boot camp, I heard this wise old Staff Sergeant tell the following story to some truculent PFC (not me):
"There was this experiment one time; some scientists took a bunch of monkeys and locked them in a room. And in this room, they had tied a rope to the ceiling and let it dangle down to the floor. And at the top of the rope they had tied a bunch of bananas. Well, any time one of the monkeys would try to climb the rope to get the bananas, they'd blast them all with a firehose! After a few rounds of this, any time one of the monkeys tried to climb the rope, the rest would start beating the hell out of it. Pretty soon, none of the monkeys even tried to climb the rope, let alone get the bananas. Then, they started to replace the monkeys one by one; a new one would come in, try to climb the rope, get the hell beaten out of it, and give up. After a few rounds, it would start beating up the other monkeys if they tried to climb the rope. Pretty soon, the scientists had replaced all of the original monkeys; none of them had been firehosed but still, whenever one tried to climb the rope, the rest would beat the hell out of it. Why? Because that's the way that things had always been...."
Somehow, this anecdote was meant as a metaphor for the Marine Corps; to enlighten us boots about why, sometimes, things that didn't make sense happened and things that did make sense didn't happen, and the perils of trying to force the system to change. The analogy isn't exact; you can change the Marine Corps, but that's a topic for another blog post. In the meantime, imagine shaking the rope to get one of the bananas to fall off instead of climbing it. Same basic idea.
And have you ever wondered why the widths of cars are standardized to the dimensions they are? Perhaps it is apocryphal, but the story goes something like this: Car widths are what they are because early car makers used wagon undercarriages as the basis for car bodies, and that's how wide wagons were. Why? Because the wheels were spaced in such a way that they would fit the ruts of European roads, and that's how far apart the ruts were. Why? Because many of the roads in Europe were built on top of Roman military roads that dated from the time of Julius Caesar, and that's how wide they were. Why? Because (and here, we finally get to the real answer), that's how wide a Roman chariot needed to be, in order to accommodate the width of the war horses pulling it. So, in some sense, the width of cars is not only an artifact of the way that things had always been, but is also an extension of the tyranny of Caesar. Remember that the next time you go pick up some groceries.
Now fast-forward to the 21st century; a mere couple of thousand years after Caesar. Look at your screen. How wide is your terminal window or the text window of your editor? 80 columns? Yeah, I thought so. Most people's are. And lots of coding standards in lots of organizations mandate this. For example, here is an excerpt from an older version of Linux kernel coding style:
The limit on the length of lines is 80 columns and this is a strongly preferred limit.
Statements longer than 80 columns will be broken into sensible chunks. Descendants are always substantially shorter than the parent and are placed substantially to the right. The same applies to function headers with a long argument list. Long strings are as well broken into shorter strings. The only exception to this is where exceeding 80 columns significantly increases readability and does not hide information.
Granted, the Linux folks give one an escape hatch for when it would be really problematic, and it should be noted that Linux has relaxed this in newer versions of the style guide. But still ask yourself: why? Why 80 columns? Why not 100, or 120, or 60?
What it boils down to is that that's the way it's always been. Sure there are arguments: printers print 80 columns of text (because they are configured to; that's easily changeable), you can have multiple 80-column windows side by side (I'll bet you can have multiple 100-column windows side by side, too. And if you can have multiple 80 column windows, you can certainly have multiple 60 column windows), the font I'd have to use for wider windows is too small to read comfortably (okay, this one I can kind of see, but that's an individual thing, no? What if I need such a big font that I can only see 40 columns on a window?).
So again, why 80? What makes that number so special? Why do printers print text files in a font so that each line is a maximum of 80 columns wide? Why is the default xterm window's dimensions 80 columns by 24 lines?
Let's back up for a second: the answer lies in history. Xterm windows default to 80 by 24 because that was basically the size of a VT100 terminal window. Introduced in the 1970s,The VT-series terminals used 80 column line widths because they were common in the industry and particularly in terminals from other manufacturers. But why did terminal manufacturers care about 80 column widths? 132 columns was a popular width back then as well, so why don't we use 132 column windows? Because, my friends (and here we come to the real reason) 80 columns was the width of the Hollerith punched card, and cards were, at one point, the preferred input mechanism for nearly all programmers and computer systems.
And in this day and age of high resolution bitmapped displays with millions of colors, driven by the supercomputer-crushing performance of modern graphics hardware, your xterm window emulates an 80 column VT100 in order to provide some semblance of compatibility with 80 column Hollerith punched cards that date to the 1920s and were common on the IBM 1604. Nevermind that most programmers these days have never seen a punch card being used, nor seen a VT100, let alone used a serial terminal with a fixed display size. (For extra hilarity, ask your colleagues whether any of them have ever deliberately misspelled an identifier to avoid wrapping a line.)
Now, this isn't to say that 80 column lines are inherently bad. But it is to say that unchallenged devotion to a limit that is fundamentally tied to an ancient hardware standard that no one uses anymore, without questioning the underlying rationale, is bad.
How many times have you had to break a line of code in an awkward (if not outright ugly) way just to keep it under 80 characters? How do you feel knowing you did that to maintain compatibility with hardware you've neer seen? It's kind of silly, isn't it?
Further, I claim that insistence on these rules, and the ugly and awkward line breaks they cause, decreases understanding and hinders accessibility. Visual line breaks in the middle of programming statements put cognitive load on the reader. For something like a screen-reader, they break the cadence of speech in the same way. If goal is comprehension of the code, this seems suboptimal (though, in fairness, people quickly grow accustomed to a consistent standard and it becomes less of an issue).
This isn't to say that one should go crazy with super-long lines: they also hurt readability and comprehension, and one should exercise good judgment in determining reasonable line lengths. Slavish adherance to an arbitrary limit tied to an irrelevant hardware standard is counter-productive, and there are ways to make lines some reasonable length without enforcing made-up declarations, such as editorial judgement exercised through code reviews.
If programming statements are like sentences in natural language, then too-long lines are like run-on sentenes. But breaking the statement arbitrarily at some point seems more like saying that you have to end a sentence at the end of each line, whether the sentence is finished or not because, you know, that's the way it's always been done. (I know it's not a perfect analogy.)
So when you see something about 80 column line widths, in your own code, a window on your screen, or a rule in some project or organization's coding style documents, know that we're still holding ourselves prisoner to the Tyranny of the 80 column Hollerith Punched Card. Especially remember this the next time you have to wrap a line in an ugly, inconvenient way and say to yourself, "that would have fit in 81 columns!"
Now, just for laughs, run stty
inside your
xterm or in Terminal.app and tell me why your window has a
baud rate.