Prototype and Script.Aculo.Us

You Never Knew Javascript Could Do This!

Using the Prototype and script.aculo.us Javascript libraries to simply your life.

Partly due to their association with Ruby on Rails, Prototype and script.aculo.us have become two of the best-known Javascript libraries in the last few years. While there is no shortage of articles and examples on the web on how to use them, I don’t know of any other English-language books devoted solely to either at this time. That said, at least one more Prototype book is coming out this spring, but “the bungee book” came first. What Christophe Porteneuve’s book does is offer you is an insider’s view (the author is part of the core team developing Prototype) of the library. The book will fill in a lot of the gaps in the online documentation, or at least brings together things that might take a lot of Googling to track down.

The first part of the book covers the Prototype library. Prototype adds a fair bit of functionality to the Javascript language and makes working with the DOM, forms, Ajax and the JavaScript language itself a fair bit easier – or at least less typing. Some commentators have suggested that Prototype tries to turn JavaScript into Ruby, I don’t know enough about Ruby to comment on this, but there is a fair number of references to Ruby when discussing features. As well, all the server-side code (used in the Ajax sections) is written in Ruby. If you need a primer on Rudy, the appendix explains how to install it as well as links to websites that will teach it- there is no tutorial in this book.

READ  The Definitive Guide to Drupal 7

Coming from a PHP background, it took a bit of work to follow the server code. However, I don’t think re-implementing the code in another language would be complicated as the authors lay out what the server code is meant to accomplish. On the other hand, the JavaScript in this book is not the simplest. Readers should have a good grasp of the language. If not, I’d suggest picking up something like Pro JavaScript or similar if you want to get the most out of it.

While Prototype builds on JavaScript, the script.aculo.us library, builds on top of Prototype, adding many of the common “Web 2.0” elements: drag-and-drop, auto-completion and other animation effects. Readers looking to add these effects right away might want to skim the first half of the book though before diving into the second half.

I’m not a big fan of books that devote pages to listings of code and this book, fortunately, doesn’t do that a lot. They also print a URL to download the code, right above the listing which is a nice feature that I haven’t seen in many books before. While on the layout itself, the book is about 400 pages, it’s black and white, not the most inspired layout but still clear.

I learned a lot about Prototype from this book, beyond the $, $F and $$ bits that have since shown up in other libraries, most notably jQuery. There’s a lot of functionality that’s probably overlooked by casual users. That’s the greatest strength of this book – it shows you a lot of things you probably didn’t know either library was capable of. I’ve been using Prototype and script.aculo.us for about four months now in a variety of small projects. Hence, there was a lot of material here that I probably would have discovered eventually, but this book covered a lot of stuff that I wasn’t aware of.

READ  Learning HTML 5 Game Programming