80 Columns is Enough

Just saw this question up at Slashdot. If you ask me, this is the voice of the clueless. Sure, 80 columns is insufficient in a term window. I typically run mine 110 wide. But that’s not the point of why many coding conventions have a bias towards 80 columns. Well, it may have been originally, but there is far more value to this restriction than ancient termcaps dictate.

Functional decomposition teaches us that to manage complexity code should be digested into manageable chunks. For C-like languages, and many others besides, nesting depth is often a good cue where a particular function is doing to much and should be re-factoring into smaller pieces. If I write a section of code that continuously overflows 80 columns, well, a good bet is it is nested a bit deep. I may also be violation the Law of Demeter by dereferencing too deeply.

The point is that 80 columns is not as arbitrary as it seems. Nor is it strictly a historical artifact. As we code, we need reminders, sing posts, that help us be mindful of what we are doing. Having pulled a couple of marathon hacking runs, recently, the siren song of code is fresh in the mind. If you are too fixated on the source at hand and don’t use these cues to pull back and continuous check and re-consider, well, that’s how smelly code developers.

So keep your code to 80 columns. Understand why you do it, of course. And developer any other practices and tricks that keep you mindful of what you are doing and re-assessing so your code is ultimately the best you know how to write.

Leave a Reply

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