1st January 2006

Posted in

Blog :: It's a New Year

I've been feeling stunted in my development as a programmer for some time now and I recently had a revelation about it. I was rereading some of Paul Graham's older essays and realised that I had a problem. Take his Beating the Averages essay, for instance. You have to read it, but to synopsize: He argues persuasively that programmers tend to see things from the perspective of the languages they already know. Looking at less powerful languages (say assembly) it is immediately obvious how syntactic constructs give my language of choice more power. Looking up at more powerful programming languages, however, it is not so obvious: they all look like they do what my language of choice does, plus some weirdness.

I was thinking about this as I browsed. Next I was reading his Revenge of the Nerds essay and thought for a moment about his footnote about accumulators. In the context of talking about the expressiveness of programming languages, he considered the following problem:

write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i.

(That's incremented by, not plus. An accumulator has to accumulate.)

I was, of course, immediately thinking about how to do this in PHP*. As I was considering, however, a nagging thought kept persisting: "why the heck would anyone want to do this?" This was my aha! moment. I'm looking up at programming languages whose expressiveness is more powerful and wondering why you would do something strange. Could it be possible that the something strange is actually useful but I don't recognise it because my language hasn't exposed me to it? When I think about it, I run into this feeling all the time. Everybody is always talking about closures in Ruby, and I wonder "whats the big deal about closures? Functions that capture their enclosing state? How would that be useful?" (Substitute generators in python, continuations in smalltalk (because of Seaside), or even macros in lisp for other examples). I don't like this feeling, and so I will combat it with the following New Year's Resolution.

Since actually understanding a language requires experience programming, not piddling around, I will write a small app in python in the next several months. Likely it will be a mass image resizing program (gui interface to ImageMagic; this is a longtime goal of mine actually) but I will not use an ide or form designer for the layout. In the process, I will read up on python's more advanced features and consider how they might help my coding skills... When I am done I will post the code and app for public use.

* You could do the class thing (like the python example), but more, uh, PHPic would be:

function foo($n)
{
    return create_function('$i', 'static $n='.$n.';$n+=$i;return $n;');
}

Works for me...

Update: Raganwald nails what I'm talking about...

Posted on January 1st 2006, 10:50 PM