In "Higher Order Perl" (or HOP as it's affectionately called in the Perl community), the renown Perl wizard Mark Jason Dominus (MJD) shows how to take Perl coding to the next level by applying advanced programming techniques from the domain of functional programming.

The book covers recursion (including methods to convert recursive code to iterative code), iterators, streams, memoization, currying, parsing, constraint programming and higher order functions (functions that take functions as arguments and/or return other functions). It is packed with great, sophisticated code which is explained very well and is a model for correct programming. The author takes an approach similar to Peter Norvig's PAIP - advanced coding techniques are presented, and then non-trivial programs are written to demonstrate these concepts.

The comparison with Lisp here is unavoidable, and MJD talks about Lisp in his preface. He claims that Perl shares 6 of the "7 features unique to Lisp" quoted from Norvig's PAIP, and that this basically means that most of what can be written in Lisp can be written in Perl in roughly the same manner. But as he himself admits in a later interview, the 7th "missing feature" of Lisp, namely its uniform syntax, is what *really* differentiates Lisp from the rest. Lisp's syntax allows a very clean handling of higher-order functions, list-processing, and most importantly macros. The contrast between MJD's own code in HOP and Norvig's PAIP code is the best example for this fundamental difference. Be MJD's code as clean and nice as it is (for Perl, anyway), it is nowhere near the sheer aesthetic appeal of Norvig's Lisp.

Still, Lisp is Lisp and Perl is Perl, and each has its respectable place in the world of programming. HOP is a great book to read, and I warmly recommend it to any intermediate+ Perl programmer. For people who have never programmed in Lisp or have never learned functional programming techniques, this book is a must - it will literally take your code to a higher level. For diehard fans of Lisp, this book demonstrates how to employ most of your favorite techniques in the most practical language out there (though the Perlish syntactic sugar will at times make your teeth grind).


comments powered by Disqus