Wednesday, May 17, 2006

Playing with Prototype

Tonight I had a chance to play with prototype, as documented here. I'm pretty much blown away at what an impressive library it is.

Prototype goes beyond adding convenience functions, to actually changing the way you think about solving problems in JavaScript. It makes heavy use of anonymous functions, and other fairly advanced features, and shows how they can be put to good use.

This also shows how flexible a language JavaScript is, in that you can extend it to add in new metaphors that simply didn't exist before.

Take some time to play with the library, and before know it, you'll be writing:

data.each(function(o) { doSomethingWith(o); });

instead of:

for(var i = 0; i < data.length; i++) {
 var needle = haystack.find(isNeedle);

Yes, I know this is very Functional/Lisp/Scheme like. But that's hardly surprising, as converting JavaScript to Scheme has been done before.

Once you've played around with Prototype, it's worth looking into Open Rico. Open Rico uses Prototype to offer a series of sophisticated web UI controls, all cleanly accessed through JavaScript.

No comments:

Post a Comment