PBP: 010 Indendation

The PBP suggests using four space indentation levels.

The book goes into many reasons for this.  It suggests that I’m an “ancient coding master” because I learned with eight columns, and find that a perfectly acceptable number.  Cue; GET OFF MY LAWN!  =)

The arguments given for eight – hard tabs go there, terminals put tabs there, printers put tabs there – seem somewhat weak to me.  Yes, those things are true.  All those devices also handle spaces just fine, and modern text-editing tools run just as well on those as they do on any xterm.  nroff has handled spacing since forever.

An argument not given is that eight spaces is a wider change, and more strongly differentiates the block, which can make them easier to scan for.

Smaller widths to maximize the number of indentation levels lead us back to the unstated desire of writing giant, hugely complex tangles of functions.  If your function needs to be eleven indentation levels deep, perhaps your design has a problem, not your tab width.

The PBP points out that smaller indentations are also harder for people with less-than-perfect eyesight to read.

I generally prefer four, though, as a happy medium.  The book has a reference to an ACM paper which reached the same conclusion.  Good enough for me.


One Response to “PBP: 010 Indendation”

  1. Aaron Priven says:

    In ancient days I used to use three, but that’s less effective when you have labels and the like on half-indent levels.

Leave a Reply