f

unk rock


JavaScript IS a High Level Language!

December 9th, 2008

In response to some extended discussion via JResig, Ajaxian, and Francisco, Charles Jolley said the following:

JavaScript, on the other hand, is a high level language. It has garbage collection, lambda functions, dynamic typing, object messages, and nearly every other feature you would expect in a modern high-level language.

When you wrap JavaScript in another high-level language, you don’t free yourself from managing low-level details; you just exchange one abstraction for another.  You pay the cost of two high-level languages without gaining any benefits for your final product.

The implication here is that JavaScript is the highest level language currently imaginable; in a word, it’s perfect. Actually, the next line, which I won’t quote, warns us not to interpret that as claiming JavaScript is perfect. It then goes on to reverse course and say the only way to abstract JS further is with a UI builder.

But is this really the case? There’s a simple test: Can I create a language on top of JavaScript that has at least one feature not present in JavaScript? Of course, the answer is yes, and the proof is Objective-J. If there is one feature that proves this point best, it’s @import. Importing is a feature that almost every high level language offers, and yet it isn’t present in JavaScript.

This begs the question: couldn’t I just implement this as a feature in a native library? Yes, and no. This is a complex topic, and I don’t want to get into the specifics, but to get the asynchronous/look-ahead code importing built into Objective-J, you need to preprocess code (aka, extend the language).

Objective-J doesn’t just add one feature, it adds many. These include dynamic message sending (which enables features like method_missing from ruby, and which is completely different from what JavaScript does have — function calls; I’m not sure why Charles called them “object messages”), importing, and classical inheritance. Many of these features use a runtime component, called the Objective-J runtime. Most of the new syntax in Objective-J is shorthand for accessing this runtime (which is built, of course, in JavaScript). You could say that the language frees yourself from managing low-level details of the runtime that you shouldn’t need to worry about.

And since Objective-J is a strict superset of JavaScript, you don’t pay any cost for utilizing it. You can drop down to “pure” JavaScript at any time. You don’t even need a compiler or a special build tool to use Objective-J, since the language is written in JS and preprocesses dynamically in the browser.

Ross at 5:30 pm | Posted in Technology, Web | No Comments