February 18, 2007

An Introduction to the Lambda Calculus

And now for something different. Are you a programmer who's made a run in or two with esoteric languages like Haskell, Erlang and OCaml, and do you find yourself confused by closures, maddened by monads and feeling downright cantankerous whenever you hear about currying? If you are, I have a suggestion for you: instead of wasting your time struggling through yet another functional programming tutorial whose writers implicitly assume that you already understand half of the new things they're supposedly trying to teach, you'd be better off giving a close reading to a paper by Henk Barendregt and Erik Barendsen called "Introduction to Lambda Calculus". This paper gives a ground-up, axiomatic treatment of the subject from first principles, and what you learn from it will have immediate application with any programming language with functional aspects, not just one particular dialect like Ruby or Lisp. You might also find this online tutorial useful.

On a tangential note, I definitely get the feeling these days that functional programming has finally come of age. First you have languages like Java and C# starting to tackle closures, then we see OCaml and (especially) Haskell showing up more and more on places like Google Blogsearch and programming.reddit.com. This is a Good Thing™ for software development as a whole (no side effects => many fewer obscure bugs), though I believe the additional intellectual sophistication required to truly understand what functional programming is all about will likely prove a barrier too high for many programmers to surmount, just as many a procedural coder never really figured out object-oriented programming. Not that "OOP only" types are going to be out of work any time soon - just look at how many PHP coders there are out there churning out write-only procedural spaghetti.

TrackBack

Comments

Amen!

As a career consultant who tries hard to actually deliver value to clients (I think of myself as something more akin to an attorney or an accountant than a schlep coder, and accept a responsibility commesurate with that), I'm shocked that so few people understand the basic math behind functional programming. I suppose I shouldn't be - there are lots of monkeys out there writing database apps without understanding at least the basics of set theory, too, with predictable results.

It might be my perverse streak, but I really like using a functional approach to writing perl, which has to be the best all-things-to-all-people language ever, including the people who love to hate it. It is sort of the anti-lisp, which everyone claims to love, but nobody writes.

Back on topic, if I could get my clients to read that paper, I would be so much happier. I do have a few IT Dirs who understood that trade-school Java isn't the end all of coding, but more would make me happy.