a review of the catalyst book

rjbs on 2008-02-17T02:30:23

In the index for "Catalyst" book, you'll find no entry for model, controller, action, dispatch, or ActionClass. These are some of the most fundamental concepts in Catalyst.

Many technical books suffer most because of those elements that are outside of the author's direct control: weird layouts, weird typographical conventions, and lousy indices. Knowing that, I'd never base my criticism of a technical book on the failings of its index. The failings of "Catalyst's" index, however, are telling about the failings of the book as a whole.

If it were only the index that lacked this information, it would be a minor problem. Unfortunately, there really is no comprehensive explanation of any of these topics. Though there is an entry for "View," it is explained in as little detail as the rest of these concepts.

Pages 6 and 7 provide about one paragraph each for the concepts of MVC, Model, View, and Controller. From there on, the book focuses on implementing specific tasks without explaining much of the concepts that are used to do so. Actions aren't so much explained as implied to be subroutines with attributes. While nearly all of dispatch in a simple Catalyst application is determined by a few named and attribute-laden subroutines, these are not even presented in a bullet list, let alone explained in any detail.

Instead of starting with an explanation of how the fundamentals works, Rockway works through specific, practical examples of application implementation. These provide a demonstration of quite a few of the things that one can do with Catalyst, and occasionally some explanation of why it works. The explanations are not systematic, however, and concepts are presented out of order rather than in a logical progression. By the end of chapter two, the first chapter with any specific examples, the reader is installing and using Template Toolkit, SQLite, and DBIx::Class. Views are defined as bits of code that produce output based on the content of the "stash" on page 20, but the stash itself is not given any explanation until five pages later. This kind of confusing presentation prevails through most of the book, and is sometimes rendered more confusing by the inclusion of huge code samples, some of which dominate three consecutive pages.

Some concepts are well explained. The section on chained dispatch was clear and concise, though basic actions and dispatch remained unexplained. The section on the REST ActionClass was clear, and I found it to be the most interesting section of the book.

The book desperately needs reorganization, both by inclusion of an explanation of the fundamental concepts used in Catalyst design and by reordering the presentation of material to present concepts in a logical order with no long gaps between items that belong together. Finally, a few segments could probably be dropped entirely, or at least moved further back into the book. Explanations of FormBuilder and BindLex, for example, might have been interesting and useful for the creation of serious web applications, but they are instead presented without much explanation in chapter three, where they just serve to further confuse the subject at hand.

The Catalyst::Manual documents seem to provide much of the same information, and at no cost. They also include some of the concepts that are missing from the book. Although I think a second edition of "Catalyst," or a second book on the topic, could be a very useful book to introduce new users to Catalyst, I don't think this book has much value beyond that of the existing free documentation.


Link

Smylers on 2008-02-17T09:57:16

Catalyst: Accelerating Perl Web Application Development by Jonathan Rockway

It's not all bad

Ron Savage on 2008-02-17T22:10:23

Well, buying the book helps support the project, and despite the problems you list, if you've never looked at Catalyst (I haven't), it's certainly a powerful incentive to anyone labouring over the construction of web apps to think much more in terms of automating construction of code, and text-based CGI field definition. And it's definitely a good thing to have such documentation, free or otherwise.
I don't reject you criticism, but I'd also add:
(1) Some specifically used concepts, e.g. $c->detatch(), desperately need explanation in the text.
(2) Catalyst is a sophisticated framework, and hence operates at a very high level of abstraction, which means I'd be reluctant to introduce beginners to it. They'd simply be having to learn too much at once.
(3) If anyone has been thinking HTML::Template was sufficient for your needs, the book makes clear you really should reassess the Template Toolkit, and I speak not just for myself :-).

I submitted about a dozen typo corrections, and I strongly encourage everyone to do the same.

my beginner's advice

mr_bean on 2008-02-19T01:45:20

First, people like rjbs are not probably the intended audience for the book. It's probably for beginners, and what beginners want to do is get a web application working rather than understand what they are doing.

The idea is to change the world, rather than to understand it. (Karl Marx)

> (2) Catalyst is a sophisticated framework, and
> hence operates at a very high level of
> abstraction, which means I'd be reluctant to
> introduce beginners to it. They'd simply be
> having to learn too much at once.

My advice to getting a Catalyst application up is to do it very quickly, so it works before the individual parts start breaking.

That's what I did, but I'm very good at following instructions.

Errata

mst on 2008-02-19T13:01:48

We're collecting errata on the new wiki (which will move onto the main Catalyst site soon).

The Review

Ovid on 2008-02-20T15:31:40

I also have a Catalyst book review I'm finishing up and I plan to post it soon. I agree that the book is aimed at Catalyst beginners. It's far more about "how" instead of "why". This means that the author doesn't have to spend a lot of time explaining core concepts (such as MVC) and can focus on the practicals, but if people need those core concepts, I still think the book has merit because they can pick up a lot of those concepts by osmosis (perhaps I'm overly optimistic).

The book has a number of weaknesses (it desperately needs some appendices and it needs a strong warning that it's not for newer Perl programmers), but I still think it has merit. Many core concepts are covered and if you're new to Catalyst, it's a great start. Is it better than the online tutorial? Tough to say as each covers things the other doesn't. The book covers more material than the tutorial but the tutorial can be updated easier. However, the book still makes it easy to follow along and if you can get past the many typos (sigh), you'll find yourself actually building stuff. How many times have you read a computer book which focuses so much on theory that you don't have any working apps at the end?