JavaScript - finally, the name makes sense

JavaScript began life in 1996 as an embedded scripting language in the Netscape browser. It was originally named LiveScript but was renamed at the last minute, presumably to ride the coat-tails of Java which was growing fast as a client-side programming platform.

Since then many dialects have been implemented on many different platforms, including the ECMA-262 standard, but historically it's success has mainly been on the client side, as a scripting language for UI elements. There were some early attempts at using it on the server, including Netscape's LiveWire scripting and Microsoft's (non-default) option for server-side JScript in ASP pages, but I don't believe either of those were widely used.

This seems to be changing lately though, and the release of Java 6 makes it official: it includes a scripting API, and though the API aims to stay relatively language neutral the default scripting engine is a slightly modified version of Rhino, the JavaScript engine.

So Sun is finally beginning to position Java the platform as being about the JVM rather than the language, the approach that Microsoft took with .NET from the start. Sun is simply trying to stay relevant amidst the growing shift to dynamic languages. Phobos is a JavaScript-based server that is part of Sun's GlassFish project, and one of its stated goals is to "appeal to developers who, for a variety of reasons, are hard for Java EE to reach". But it's a welcome change for Java developers who now have more language options while still developing for the Java platform. "Don't worry boss, it's JEE". :-P

Java developers now have options for building DSL's using metaprogramming, and for more efficient declaration of complex literals. Just imagine how much cleaner and shorter your jUnit tests would be if you set up your test fixtures like this:

var expected = {firstName:"John", lastname:"Smith", salary: 80000}

That's JavaScript object literal syntax. Try it.

Of course there are a variety of "scripting" languages available that can run on the JVM, most have been around for a few years already. Jython (née JPython) has been around since 1997(!). Groovy (though suffering slightly from infighting and controversy) has been around since at least 2003. And Sun just hired the two core JRuby developers. (There are also pre-compiled languages like Scala).

But JavaScript seems to be the one growing most quickly in popularity, partly because it's shipped by default with Java 6, and partly because there is appeal in using only one language; since we're forced to use JavaScript on the client side we might as well use it on the server too. I think the latter is a pretty weak reason though, it's good to have a working knowledge of several languages and to use the right tool for the job. (When all you have is a hammer...) Also, though it still lacks modularity, new features like array comprehensions and destructuring assignment are bringing JavaScript more in line with other scripting languages.

Or perhaps Java developers just like the name.

Categories: Software Development

Share

Like this article? I spend a lot of time writing here, it would only take a second to say thanks by sharing...

Comments

Tell me what you think on Twitter or privately by email.