Finally: A Programming Methodology for Me

Lazy programming is getting its due.

Comments (2)

  1. Larry Smith says:

    Sorry, but this is very old-hat. For starters, Google <apl drag along beating>. In particular, make note of Phil Abrams’ 1970 PhD thesis at

    For those not familiar with it, APL is an Array language and has powerful primitives to handle entire arrays in one shot. To take a trivial example, suppose you have a vector with exam scores, one element per pupil, and you wanted to pull out just the A’s and get their average. You’d probably write something like

    bool [] Mask = Scores >= 75;

    // Mask[i]=true iff Scores[i] >= 75

    int [] As = Select(Scores, Mask)

    // Just the A’s

    Total = Sum(As)

    Avg = Total / As.Length

    (Note: APL uses an extended character set, so I’ve written the algorithm using a C#-like language. The actual APL code would be *much* more compact.)

    But the thing to note is that the way I’ve written it, a naive APL implementation would make several passes over the data:

    a) It scans over the input data, producing a separate boolean mask

    b) It makes another pass, picking up just the elements that the mask indicates we want (the As)

    c) Makes a final pass over the As to add them up

    d) Then calculates the average.

    Whew, it seems that APL is incredibly inefficient. And admittedly, some implementations did exactly the above. The saving grace is that once you’ve learned to think in it (an acquired skill admittedly, but so is full C++), code can be written much more succinctly, you never have off-by-one errors, etc.

    Anyway, to address the above inefficiencies, several types of lazy evaluation were proposed. Looks like the functional programming guys are reinventing the wheel.

  2. paul moore says:

    i remmeber having the same moment of excitment with APL. The book i was using had as ats main sample a full screen editor written in about 15 lines of code. I was pumped. Then came a moment of realization: –

    Yes, I only needed 5 lines of code to do something, BUT it took me a week to write each line

    There is no silver bullet (as some bloke once famously said)