Space sensitive programming

2007-08-10, , , Comments

I recently started reading “Introduction to Algorithms”, a classic text on the subject of computer algorithms. Algorithms are described using a home-brewed pseudocode, about which the book says:

We use the following conventions in our pseudocode.

  1. Indentation indicates block structure. … Using indentation instead of conventional indicators of block structure, such as begin and end statements, greatly reduces clutter while preserving, or even enhancing clarity. [2]

Sounds good. But before we get too excited, the referenced footnote says:

2In real programming languages, it is generally not advisable to use indentation alone to indicate block structure, since levels of indentation are hard to determine when code is split across pages.

I’ll stick with Python’s conventions on this one. I can take the page-split hit — which I’d never noticed, to be honest. Reduced clutter. Enhanced clarity. Win win.