Prototype and Scripty (hereafter P&S) are packed with dense,
expressive, beautiful code, and they can do far more than their size
might suggest.

Along with several other Ajax libraries, P&S embody a modern
JavaScript style that embraces functional programming. This new style
is not well covered in the JavaScript books currently in print (as of
November 2007), so to learn P&S you also have to learn to think about
JavaScript in a new way.

Once inside the book, I was delighted to find that both of my hopes
were addressed. Porteneuve dives straight into the deep end,
embracing JavaScript’s functional style immediately in Chapter 2 and
never dumbing down the example code. (Don’t worry, there are forward
and backward references to help you along. This is especially nice if
you are reading the electronic copy of the book.) You may need to
read some sections of this book multiple times, and that is a good
thing.

The coverage of both Prototype and Scriptaculous is thorough. Of
course the marquee features receive due attention: Prototype’s
Ajax.Request and Scriptaculous’s Effects each have their own
chapters. More interesting to me is the thorough coverage of the less
visible parts:

Prototype’s functional capabilities are significantly enhanced for
the 1.6 release. Chapter 4 shows how to use curry, bind (including
multiple argument invocation), delay, and defer. You can even do some
lightweight Aspect-Oriented Programming (AOP) with the new wrap method.

Chapter 7, “Playing with the DOM is Finally Fun”, nicely mixes
tutorial and reference. The Staff Manager example motivates each
section, but each individual section also acts as a reference for a
set of DOM extensions.

The Event mechanism has been rewritten and enhanced for Prototype
1.6. Chapter 6 covers the new unified event handling. Porteneuve
motivates the event model by contrasting three approaches: the IE
way, the standards way, and the Prototype way. With 1.6, portability
improves again with synthetic events that fill gaps in the browser
event model, e.g. dom:loaded. You can even fire and respond to your
own custom events.

I have been using Scripty for years and I never even noticed the
sound API (Chapter 20).

Of course, no reviewer feels complete until a few nits have been
picked. So here are a few:

Porteneuve embraces Prototype’s approach to JavaScript and the web
(as do I). That said, there are many other approaches. It would be
great to have an overview of the philosophical differences that set
P&S apart from other JavaScript libraries.

The book’s style is casual, even by Prag standards.

Prototype and Scriptaculous are a rich buffet, and the book
documents nearly every bite. Sometimes the book could be more
opinionated about the menu. For example, I hate the $break feature in
Prototype. Maybe Porteneuve does too–the example is certainly
contrived.

These flaws are relatively minor. Overall I was impressed by the
amount of information in the book. I have been using P&S for years,
and I learned something new in almost every chapter.

For years, developers at software conferences have asked me “What is
the best way to learn Prototype and Scripty?” Until today, my answer
has always been “Read the source code.” Not any more. If you are
building applications with P&S, you need to read this book.

Rock on! Let’s all swallow our pride and make of Prototype the base for our custom tools, because there’s a need for normalizing JavaScript across browsers anyway, and it’s not easy to have several incompatible frameworks doing almost the same things everywhere.

For my part, I’ve started using it since a week ago and don’t plan to leave it anytime soon. :-)

Comment by Joao — November 7, 2007

Awesome post. …had the book for awhile as it’s been in BETA. All pragprog books I have read have been great, agree that this is no exception — great book. There is a wealth of documentation with Prototype far above any of the other libraries. It is my top choice for Ajax development because of the documentation, the community support, the support of Sam Stephenson, works nicely with jQuery, etc. (as an aside, writing code in Prototype is also a nice bridge towards programming in Ruby as a lot of the same style is employed in the prototype js lib)

The Effect.Tween is really awesome. Yet it’s code size is small and one could think why it hasn’t been there already, while I was prototyping a cover flow like effect (known from Mac) I had exactly the very problem to solve: interpolate between two values in a given time frame. A few days later the beta of 1.8 was released and within 10 minutes I got everything running because the Effect.Tween was there. That’s just awesome!

kind of following similar steps from jQuery, but still, great jobs guys and congrats.
I think there were an earlier posts regarding how to choose the right framework. Every framework has it’s trade offs, and having a few of them to compare is much better than one leading solution.

Interesting. I’m looking for a javascript library myself, since ASP.NET Ajax is just not going anywhere. This looks good (documentation is a big plus) but if I wanted a comparison (not just file size, but in depth) of the major frameworks, where would I go?