Beginning Javascript With DOM Scripting And Ajax という本で紹介されている jQuery というライブラリが興味深い。
prototype 同様、JavaScript の汎用的な機能を提供しているのだけど、記述頻度の高いコードが prototype 以上に整理されていて、パッと見、JavaScript ではない、独自言語のように見えてくる。
$(document).ready(function() {
$("#orderedlist li:last").hover(function() {
$(this).addClass("green");
}, function() {
$(this).removeClass("green");
});
});
上記は、Getting Started with jQuery に記載されていたコード。prototype は Ruby のようだったけれど、jQuery は Lisp のよう? いや Lisp をそんなに知ってるクチではないけど、Lisp 並にカッコが多くなる割に、JavaScript の原型はとどめており、わかりやすくコンパクトになっている気がする。
prototype よりも後発ということで、prototype 並みに普及するか、prototype を凌駕する存在になるか、見所。