JavaScript 2: The Next Big Language?

OK, so this blog is starting to look like the Steve Yegge Fan Club, and I’m only 3 posts in. Lucky for me, I don’t care.

Steve recently wrote a compelling post on the next big language. In my first post here, I bet that Java would be dethroned within 5 years, and Steve appears to agree. Now, he doesn’t mention which language he’s talking about, but if you read the comments (those on-topic; not those wondering how he got a hot wife), it’s pretty clear he’s referring to ECMAScript 4 (ES4), aka JavaScript 2 (JS2). If you don’t think it’s clear, I suggest you actually read the article, then his other articles (including the brilliant drunken blog rants), then Brendan Eich’s presentation on JS2. [1] At this point, it should be crystal.

As I’m always on the lookout for the next language to write my masterpiece in, this launched yet another info hunting/gathering session. JS2 looks to be a pretty nice language, the syntactic love child of Java and JavaScript, with some other goodies thrown in. And I never had a big problem with JS1.x. In fact, I’ve got solid anecdotal evidence that just about everyone who hates JavaScript never bothered learning it like a real language, picking up the rhino book and reading the gory details section. The haters all see JS as an obstacle, a necessary evil thrust upon them by the need for client-side validation, so all they do is blindly stumble around, trying to twist some working script to their needs. Yeah, some haters are cunning programming linguists who hack out parser generators while waiting for their triple-grande cafe Americanos, but they’re a tiny minority. Plus, they hate all languages.

Anyway, I found out a lot. ES4 is already available, (more or less, as the spec isn’t finalized) in Adobe’s ActionScript 3 (AS3). Yes, the language used for Flash. Adobe built a virtual machine for it, codename Tamarin [2], aka AVM2. It’s been embedded in Flash 9, and it’s supposed to be wicked fast. It’s also been open sourced and donated to Mozilla, so it should show up in Firefox 3. [3] Frank Hecker wrote a nice piece on what impact this will have.

So soon you’ll be able to use the same language for Flash apps, Flex 2 apps (which is a lot more up my alley), and AJAX. That’s a big motivator to learn it.

The only place it’s missing is the JVM. Now, if you read carefully, Steve said it would launch on the JVM. Unfortunately, I’m not so sure. Rhino, the embedable JS interpreter/compiler for the JVM, can only handle JS 1.5. I figured, hey, they just added it to Java 6, of course they’ll maintain it and keep it up. But we’re up to JavaScript 1.7, and it’s still not there. So I focused my search for a Rhino roadmap, and you know what? There pretty much isn’t one. The best source I could find was this thread on, concerning the implementation of ES4 features in Rhino. I found it scary for a few reasons:

  • There appears to be only one active committer, and just a few other helpers. Apparently Sun does not have any engineers devoted to Rhino.
  • Modifying Rhino to handle ES4 is a daunting task. Rhino was initially a straight port of Spidermonkey, which was written in C.
  • The other option suggested is creating a straight port of Tamarin. Tamarin was written in AS3, essentially JS2, which should be easier to port to Java than C was. But it’s 135,000 lines! And in a much terser language than Java! So who knows how many lines the port will end up being. An AS3-to-Java compiler seems like it would take less time, but that still sounds like a major effort.

I’ve also seen a couple instances (PHP, Python) where someone connected Java to a native implemenation of a language. Perhaps they could do that with Tamarin, although I wonder about the performance. Would it be better than a Java implementation, or would the overhead hurt it too much?

So I’m bummed, as I’m looking for something to help me script Java (actually, replace it in the middle – and possibly presentation – tier), but I don’t want to choose a dead platform. To use JS2 server-side I’d have to give up Java altogether, and that seems like cutting off my nose to spite my face, or throwing the baby out with the bath water, or some other such calamity. There are just too many Java FOSS libraries, which solve really hard problems, that I’d have to give up.

So I’m going to have to size up JRuby some more, and perhaps do a bit more digging on ES4, before I make any rash decisions. Procrastination wins again!

[1] BTW, the presentation uses some new HTML/CSS/JS document format to replace PowerPoint, and you have to point your mouse in the lower right to pop up the controls. Crazy frustrating if you don’t know that.

[2] It’s a monkey, like Mozilla’s C-based JavaScript engine Spidermonkey. Not tamarind, the seed that makes a delicious sweet and tangy sauce for my samosas.

[3] If Microsoft was smart, they’d use it for IE8, assuming that’s legal and wouldn’t cause Mr. Gates to have an aneurysm.