(re-posted from my blog entry)
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).
James Gray is a seasoned Ruby veteran who has been adding value to the community for a long time. One of his major contributions is the Ruby Quiz - a competition modeled after the Perl Quiz - each week a new challenge is posted and people are encouraged to contribute solutions. In the end of the week, James analyzes the most interesting solutions and presents a summary on the website (and the mailing list).
This book is a digest of the 25 most interesting quizzes and their solutions carefully collected by James and released in one volume (using some very pretty typesetting, I must add). It’s basically a printed version of the website, with only very little content added - like additional exercises after each quiz.
And this is where the problem of this book lays, in my opinion. To experienced programmers it won’t be particularly interesting, since looking at the quiz website itself and participating in the lively discussion on the maling list is much more interesting.
This book could be excellent for newbies, but unfortunately it’s not meant for those unfamiliar with the language. So even here, the website is just far more useful. The only real advantage of this book is its dead-tree format, which may be nice for people who have difficulty reading from the computer screen, or for people temporarily without internet access.
My journal has moved again, this time to its final location on my domain: http://eli.thegreenplace.net
It's now powered by Wordpress and includes RSS and Atom syndication. If you're interested in following my Perl posts, you can subscribe to the Perl category of my RSS feed.
use.perl.org has been a nice place to post my blog to in the past 3 years (almost). So, now it's time to move on - my new blog is http://eliben.blogspot.com.
Although I moved all entries to the new blog, I will keep the archives here as well, just in case.
As I mentioned yesterday, I'm playing around with Blogger, trying to post all my old use.perl posts there from a script.
Blogger has an old API which is based on XML-RPC, and is too weak to be anywhere near useful. It doesn't allow setting post titles and dates, for instance.
Fortunately, they also have a new Atom API, which has these features. However, it is much more difficult to use, and the information about programming Atom clients is still too scarse. Anyway, I found a Perl script that manages to access Blogger via Atom, using LWP::UserAgent and HTTP::Request (with authentication over Crypt::SSL). I made some changes to it to fit my needs and now I'm finally able to post entries with titles and dates.
I already dropped all my use.perl entries into xml files on my PC using WWW::UsePerl::Journal, now all that's left for the transition is to upload all these posts to Blogger.
Typically, though, I have just the idea to make my life more difficult. Since I'm now feverishly learning Ruby, I decided it would be symbolic to use Ruby instead of Perl to port my entries away from use.perl
So, I started porting the Atom-access script from Perl to Ruby. LWP::UserAgent and HTTP::Request are replaced by Net::NTTP and its subclasses and mixin modules (a wonderful Ruby feature), and the SSL is handled seamlessly since Ruby comes with OpenSSL preinstalled. I managed to port almost everything, and now just have one little problem left before my Ruby script is fully functional to do its job.
When I'll finally finish it, I'll post a how-to on my new Blogger blog.
On Friday I was contacted by a Google headhunter, offering a few position in Google's various labs. Unfortunately, I had to refuse since I have a signed work commitment for the next 3 years. I'm not sure how that would work with my being an Israeli citizen, anyway.
Oh, and by the way, it looks like Google is going to open a R&D lab in Haifa sometime soon. Maybe I'll end up there eventually
I'm considering moving my blog to www.blogger.com
For that, one of the requirements is to be able to back-post all my use.perl journal entries, automatically of course.
I have a Perl script that archives all my use.perl entries - all I have left is to post them to Blogger. They have a XML-RPC interface which I can access with Perl/Ruby, but so far I haven't found some vital features, like how to set the post title via the API or how to change the post date.
(read in Russian)
Doctor Zhivago is a very difficult book to read, but I found finishing it is quite rewarding. The beginning is particularly dense with the author following a lot of characters in parallel. As expected, however, this turns out to be planned as most of these characters turn up in un-expected places in the later parts of the book.
The protagonist of this book is Dr. Yuri Zhivago. This man is torn - between two women, between his love for his motherland and the hate for the revolution, and between a desire to write and the need to work hard to sustain himself and the people around him during one of the most difficult periods in Russian history.
This period - during World War I and the Russian Revolution, is indeed terrifying. We as readers see through the book how life of intellectual people from Moscow, people considered "middle-class", were reduced to a pitiful existence in poverty and a constant fear of random arrest and execution. No wonder this book was forbidden in the communist Soviet Union - the rulers certainly wanted to paint the "great communist revolution" in brighter colors than the gloomy picture Pasternak presents.
Yuri Zhivago has aspirations to become a writer - this is presented beautifully as he looks at the work table (in a home he, Lara and Katia were hiding in) with awe and a sweet expectation to sit through the night with a candle, writing poetry and prose on his life views. Through this and other events (like Yori and Lara's touching love) the book shows how even in the times of terrible hardships, life has its little beautiful moments.
But let me return to what I said in the beginning of the review - this book is difficult. It uses a lot of metaphors, philosophic ramblings and the plot is not always easy to follow. It was difficult reading for me in the book's (and my) native Russian language, so I hope the English translations at least don't make it even worse.
This book is a mixture of an auto-biography, history, literary criticism, feminism and the connections between these topics. The author, Azar Nafisi is an Iranian literature professor living in the United States. In this book she tells about her life in Iran from the end of the seventies to the end of the nineties.
Nafisi taught (mainly English) literature in a university in Tehran for most of this period, and also held a weekly book-club meeting with several bright students in her home. During this time, she read and taught about a lot of classic books, and had time to ponder about their connection to the daily lives of people (especially women) in Iran.
There are a few things I liked and a few things I disliked in this book. First with the good things:
I really loved the historic account of life in Iran during the Muslim revolution, the Iraq-Iran war and after that. It's a really rare insight into a country that doesn't expose much of its inner-goings to the outer world. Having recently finished a couple of books about Soviet Russia, it's hard for me not to draw the obvious connections and similarities between two totalitarian goverments, which are in one sense so different, and in another so similar. In one the "rulers" are driven by an economical ideology and in another by religion, but the consequences on the "little people" are mostly very much alike.
I also liked the bits of literary reviews of some classic books by Vladimir Nabokov, William James and Jane Austen. The author is certainly a gifted literary critic, she really "gets" these books. The ties drawn between fictionary lives and real ones are sometime very beautiful. The way people whose real-life is hard and consists of a seemingly poitless struggle find a parallel universe in books is touching.
Of the stuff I didn't like is the repeatability, over-abstraction and excessive feminism. The author repeats herself quite a lot, and some of her writing about her feelings and memories ranges from over-abstract to plain unclear. These things make this book somewhat difficult to read.
Kent Beck is one of the most known proponents and "spreaders" of eXtreme Programming, and is the author of the excellent "Extreme Programming explained" book. In "TDD by example", Beck tries to expand on the topic of test-driven-development (in short TDD), providing some examples and "testing patterns".
Unfortunately he failed in this task. "TDD by example" is a blunt, boring book which adds nothing new over the "Extreme Programming explained" primer. The examples are trivial, over-chewed and don't teach almost anything useful. The philosophy he presents is way "over-extreme", and I seriously doubt that anyone programs like that. What us is really in an example that "tests" the function add(a, b) which performs... that's right - addition of a to b. Beck "test drives" by writing the test "assertEquals(add(2, 2), 4)" and "just to see the green bar" implements add(a, b) as "return 4". Come on !! What does this teach ?
The last part of the book, concentrating on "design and test patterns" promised to be interesting but proved to be just a dry recycling of some points from Fowler's "Refactoring" book. The only thing I did learn from it was some interesting usage of Mock objects. At least it wasn't completely useless
All in all, if you're even a little familiar with XP, this book is a waste of your time. If you aren't familiar with this method of development, by all means read Beck's fine "Extreme Programming explained".