A response to jQuery

JavaScript language abstraction

I just read this blog article by John Resig, the author of jQuery. The article in general is a criticism of various projects like my very own “JASPA” – A criticism of frameworks that attempt to bring JavaScript into the 21st century by abstracting it into a different language.

I knew I wasn’t alone with JASPA – There is GWT and Jangaroo for Java, Pyjamas for Python, and Cappuccino with its own syntax called Objective-J. These projects are all slightly different takes on one core principal – that to truly make JavaScript “better” you can’t just write JavaScript, you have to introduce a more advanced syntax to leverage more advanced features.

Understandably JavaScript evangelists like John don’t all like this idea, and I do understand why. John makes some good points; most of which I completely agree with, but also some that I feel apply equally to his own jQuery and libraries like it.

Native JavaScript vs foreign language syntax

Pure-JavaScript libraries like jQuery, Prototype, Base2, (the list is endless) all attempt to address the short-comings of JavaScript from the inside, so to speak. That is to say that they are implemented in JavaScript and can never escape JavaScript. John argues that this is preferable, but I argue that the way in which these kind of libraries attempt to bend the syntax of JavaScript make them guilty of most of the same charges. Furthermore I argue that these libraries stand in the way of someone new to JavaScript gaining any real understanding of it.

My main defence of JASPA is of course that the language syntax is that of ActionScript (AS3), which regardless of its rocky relationship with ECMAScript 4, is still an evolution of JavaScript, and not a total departure from it, which is what John Resig seems to be most offended by.

So naturally I posted a comment about my feelings..

.. except not only did I manage to cock up the posting of the comment, but for all I know it will be taken down to punish me for my shameless self-promotion. So because of these reasons, and because I feel I made some good points, I thought I’d re-post my comment here with a tiny bit of editing.

--8<-------
I see your point when it comes to non-ECMAScript languages, but what about ActionScript? I chose AS3 to implement my “abstraction” called JASPA – jaspa.org.uk

I know many JavaScript evangelists reject ActionScript, (especially due to its recent history with ES4), but it’s like writing an extended version of JavaScript rather than a whole different language.

The OOP enhancements in ActionScript are intuitive and the syntax for procedural code remains largely the same. I would in fact argue that the OOP enhancements in ActionScript are much more intuitive than constructs like this:

$(document).ready(function(){
   // ...
});

– or sugaring approaches like this:

Class.method('example', function(){
   // ...
});

I appreciate what these kind of constructs achieve, but I cannot agree that they are particularly intuitive or respectful to the natural form of JavaScript. I would go further and suggest that people who aren’t JavaScript experts may not see how these formations really relate to JavaScript syntax, particularly due to the use of whitespace.

There some libraries that convert functions to strings and overwrite them with altered versions – surely this approach is even less intuitive and has even less respect for JavaScript than an extended form which provides real OOP enhancements such as classes, packages, imports, and super; not to mention strict typing.

Anyhow, I would ask that anyone looking at JASPA realises that what I am doing is purely out of respect for what JavaScript is and what it isn’t.