Wednesday, August 17, 2016

Another software engineering glitch in Cormen et al.

The authors of introduction to algorithms have a function that takes four arguments: an array, and three indices into that array, a low index (low), a middle index (mid), and a high index (high).

Of course, there is no computational reason to pass those three indices in any particular order: the computer doesn't care. So our only concern in deciding what to to order to pass them should be to make it easy for the programmer to remember the order and get it correct.

And what order makes that easiest? In a culture that reads left to right, I am pretty sure we should pass (low, mid, high). Right?

I spent a half hour looking for a bug, finally discovering it occurred because the authors decided the best order to pass these arguments in was (low, high, mid).

Seriously guys, WTH?


  1. Shoulda used a language with named arguments.

    1. Well, they are writing pseudo-code in no language at all, and they are trying to use only common features of most languages. So I understand them not using those.


An orgy

“The advancement of science and the rationality of politics are interwoven in a social process that, in the perspective of a more distant f...