October 25, 2008
MarkBernstein.org
 
Follow me on Twitter

Practical Prototype and Script.aculo.us

by Andrew Dupont

When chemists consult a volume about professional chemical technique, or when surgeons reach for the latest update on neuroanatomy, they can usually find a book that isn't couched in terms of silly examples and jokes. So can poets, mathematicians, and geologists. For some reason, though, it has become the accepted practice that language manuals should spend lots of time with silly, self-deprecating jokes, and that their example applications should be breakfast loggers and fantasy football leagues (or, conversely, payroll programs).

This is a fine book. Well written, solid, readable. It’s not fair to blame Mr. DuPont for the general vice.

But let's face it: Prototype is 4,000 lines of Javascript. We don't need to sugar coat it. Besides, these aren’t really libraries that your grandmother is going to need; the audience for this volume (series slogan: books for professionals by professionals®) is composed of motivated people who know something and who have been around the block once or twice.

So, a good book. But take out the jokes, trim back the sample code (or dispatch it to the Web site where it makes more sense), and give us to professional perspective, and everyone is going to be much happier. How does Prototype+Javascript relate to other languages — C++/STL, say, or SELF? What, precisely, are the semantics of the key methods? I don't need the inevitable chapter 1 pitch for the wonderfulness of Javascript and the badness of MSIE, but it might be a good place for a quick summary for the pros. Call by reference • no pointers • primitives are objects • everything has a prototype slot • parens() do this, braces {} do that, brackets [] do something else • single and double quotes are different. Kernighan & Ritchie did this so well in C, and it’s not like we’re not familiar with their example.