Book Report: MooTools 1.2 Beginner’s Guide

Saturday, February 20th, 2010 @ 11:40 am | filed under: MooTools

I’ve written a lot about MooTools over the last several years, the mootorial, my own book, not to mention all the posts here and loads of documentation. So you might think that I’d look at another MooTools book on the market as competition but you’d be wrong. I love that there are other people out there who want to help others learn MooTools. Writing tutorials and books is just as valuable to the framework’s growth as writing code. In the last year there have been a lot of new materials on that front now that I think about it. Ryan Florence has dedicated his blog to the topic. Mark Obcena has written a whole series called “Up the Moo Herd” that covers a lot of tips and tricks and best practices. Not to mention all the great work David Walsh continues to do (for instance, his recent post on NetTuts – “Make your MooTools Code Shorter, Faster, and Stronger” – was terrific).

So yeah, another MooTools Book? AWESOME.

MooTools 1.2 Beginner’s Guide

First thing I’ll say is that this book (get it on Amazon | free chapter pdf) is very much different from my book in several notable ways. For starters it’s much more of a cookbook than a reference guide. It focuses on teaching through examples and doesn’t concern itself with nuance really. This book shows you how to do the common, basic things you would want to do with any JavaScript framework. You learn about DomReady and Ajax and Animations – all the stuff that attract you to using JavaScript. As such it’s clearly aimed at people new to the language. It doesn’t spend a lot of time explaining the deep details of inheritance, binding, closures, etc.

I’d argue that, if you’re new to JavaScript, it’s a far better book than mine. It’s easy reading, the voice is fun and good natured, and the examples are really easy to understand both conceptually and in their implementation. Because the authors don’t focus on nuances they’re free to just illustrate solutions, and I think that, in general, this is probably an easier way to learn.

What do I mean by “not focusing on nuances”? It’s all the little things that come with any programming language. It’s the part of any programming solution that goes, “Here is how you solve that problem… unless you have this other condition…”  For example, MooTools 1.2 does not have a unified Fx timer (this is changing in 2.0) which means that numerous instances of Fx running at the same time can compete for CPU resources, making transitions bog down and become choppy. The solution is to use Fx.Morph, for instance, when you want to transition more than one style property on a single element, but if you’re animating more than one element, you should use Fx.Elements. By not getting bogged down in this nuance, this book is more free to just say “here is how you use Fx to animate an element’s styles.”

Now, to be fair, the book does cover Fx.Morph and, in a later chapter where it covers the MooTools More plugin repository it mentions Fx.Elements. It’s not like the book doesn’t cover a lot of ground, but it focuses more on teaching with simple examples. There’s just a lot of these types of things it doesn’t cover, which makes the book kind of hard to read if you’re well versed in how MooTools works; not that you would read it if that were the case.

The book has chapters on the basics of getting the library and installing it in your pages, writing classes and using them, DOM manipulation, the Core utility functions, events, Fx, Ajax, MooTools More, and how to write your own “plugin” (which is really just more on Class usage).

If I were just picking up MooTools I think that this book would feel like downloading MooTools was an adventure. It opens up a world of cool functionality that anyone can apply to their work without much effort. If I were a good programmer – and maybe already well versed in JavaScript – I’d probably finish the book and have a lot of questions, most of which can be answered by reading materials online or, better yet, downloading MooTools and reading the source itself.

If there’s one thing that I wish the book had covered, though, is the notion that writing classes with MooTools is the predominant programming pattern. When I write Javascript, easily 95% of my work is encapsulated in objects and classes. The MooTools 1.2 Beginner’s Guide covers a lot of ground, and it does show you how to write classes, but it doesn’t really talk about why you really should. Most of the examples are just expressive statements inside a DomReady wrapper. It’s a great way to quickly illustrate how to get something to work, but the next step to me should have been to take one of these examples and illustrate how putting it into a class gives a lot more power to you. The chapter on how to write your own plugin (which would have been more accurately titled “How to Write Your Own Class”) illustrate the process, but not really the value.

This is, in the scheme of things, not a big deal. Anyone picking this book up to learn MooTools is going to get a lot of value out of it and hopefully get hooked on the power of MooTools. As they start using that power they’ll figure out how to encapsulate it more effectively in objects and classes sooner or later.

As a beginner’s guide, the book is very successful. If you’re new to MooTools, and especially if you’re new to JavaScript, and you’re thinking of buying one MooTools book, this is definitely the one to get.

(get it on Amazonfree chapter pdf)

Comments are closed.