software mastery, the fun way

Google Dart? Don’t bet against JavaScript

Google Dart? Don’t bet against JavaScript

Procotols, programming languages and operating systems all compete in a constantly evolving software ecosystem. Out of that ecosystem only a few technologies truly have staying power and survive over the long term. An example? How about Ethernet? It’s been a survivor over the last thirty years despite existing in a constantly changing landscape that’s been populated with many worthy competitors. Ethernet’s grasp has been so strong, there even an informal law, known as Metcalfe’s second law, that says “never bet against Ethernet”.

Let’s take another example: HTTP. For an almost simplistic transport protocol HTTP has taken us a long way. No more is it just for shipping around web pages; HTTP has been purposed for each new use case that hits the web, like structured data (XML, or JSON if you prefer), asynchronous web calls (Ajax), and more recently, even adaptively streamed video (HTTP Adaptive Streaming).

We’re sure you can come up with other examples of technologies with staying power (HTML is an obvious choice, especially after beating down XHTML 2 in the last few years and with the rise of HTML5), but we’d like to suggest another technology we think has true staying power: JavaScript. In fact, JavaScript has fought off an impressive list of contenders over the last decade and a half. Consider a few of the more notable ones:

  • Client-side Java (Sun Microsystems)
  • VBScript (Microsoft)
  • Tcl/tk (Sun Microsystems)
  • JScript (Microsoft)
  • Flash/ActionScript (Adobe)

JavaScript’s been so successful it has now been declared the standard HTML language by the W3C (yes, you can even remove that type="javascript" on your script tags if you want). And JavaScript is just now beginning its renaissance period. Not only does JavaScript play the commanding role in HTML5 web applications (and the HTML5-related APIs these apps use), JavaScript is also receiving the attention of some of the best brains in the industry, who are focused on improving its runtime speed and footprint. And, if you haven’t heard, over the last five years or so, the improvements in JavaScript’s performance are impressive.

So with JavaScript the reigning champ in client-side scripting/programming, what’s this we hear about a new challenger, Google Dart? What is Dart and is it a challenger to JavaScript? Google Dart is a Java-like language that includes many modern programming language features and comes bundled with the GWT and DOM libraries, so you can use it, like JavaScript, to write general client code in a web page.  Google says that with Dart, they are trying to address a “fragmented mobile platform,” increase performance and developer usability, and address the language failings of JavaScript.

We won’t disagree that JavaScript has some warts1. JavaScript was created in the flurried early Netscape days by Brendan Eich, and wasn’t the child of slow, careful design and implementation (unlike many programming languages that are the children of long development by academia). But careful planning isn’t everything, and Brendan created a very interesting and powerful language that often gets too little credit. For example, JavaScript’s object system is actually more powerful than a classic OO system, and can even be used to implement classic OO, should you want to do that.

Looking beyond the technical prowess of language features for a moment, one of the things that makes JavaScript interesting is that it is approachable for new and more novice programmers. Let’s remember, one of the reasons Java is argued to have failed in the browser is its complexity compared to JavaScript, especially for web scripters or those new to programming. In fact, the knowledge you need to write a small piece of code in JavaScript is quite small compared to the learning curve of a “hello world” app in Java, where you need to know about classes, void types, static methods and access modifiers:

class HelloWorld
{
        public static void main(String args[]) {
           System.out.println("Hello World!");
        }
}

And Dart is similar to Java. With JavaScript, a casual programmer often throws in a few global variables, some top level control, some calls to update the DOM, and she’s done. Many have argued against this sort of programming style (and when writing applications of complexity, we agree), but JavaScript is sufficiently capable of supporting the spectrum from casual programming all the way to the modular development of sophisticated libraries. JavaScript’s simplicity has value, and like Ethernet, HTTP, HTML and a number of other successful technologies, it is this simplicity that gives the technology staying power.

This isn’t to say Dart won’t ultimately be successful to some degree or even wildly successful within some subset of the developer community–it may. But we’d guess that Dart will more likely succeed as a higher order tool to create client side applications (perhaps using its ability to generate JavaScript code) rather than as an outright replacement for JavaScript. In fact, we’d argue that HTML5 is going to drive a whole new set of tools for creating web content, that will all ultimately generate the lingua franca of the web: HTML, CSS and JavasScript.

Of course, some are already saying about Dart, “Wow, Google’s behind it, it’s going to be big”; well, we say “remember Google TV, and Google Buzz, and …”  But, more seriously, Dart already has a few hurdles, like browser support: Chrome is currently the only browser that natively supports Dart.  On the mobile front, JavaScript is already well on its way to being supported across the entire mobile device landscape, and of course, in desktop browsers, JavaScript has been king for years. It would seem the only path to solving the fragmentation problem would be to continue to improve JavaScript, not create a new contender that faces a huge, uphill battle of developer adoption.

Brendan Eich (currently CTO at Mozilla) said in his TXJS talk: “I’ve spent the last 16 years betting on the Web. Evolving systems can face collapses, die-offs, exigent circumstances. I don’t see JavaScript under imminent threat of death due to such factors, though.” We’re not betting against JavaScript either. It is the defacto scripting language for the web, implemented in just about every modern browser, with many smart people working to make JavaScript a better language every day. We’ll keep an eye on the development of Dart and see what happens.

Eric Freeman and Beth Robson are Principals at WickedlySmart, and co-authors of Head First HTML5 Programming, as well as Head First HTML with CSS & XHTML.

1 The EMCAScript group is doing some terrific work on JavaScript, really pushing the language forward and attempting to address many of JavaScript’s warts.

  • http://www.facebook.com/profile.php?id=501050798 Erik Bianchi

    I’ve messed around with DART. I do like it better then JS, then again it feels like an old friend. However, I think it does have some hurdles as you’ve mentioned. Mainly browser support and googles habit of dropping products that don’t catch on. I’m just disappointed ECMAscript-262 edition 4 was scrapped.

  • http://twitter.com/swVisionary Nick Vaidyanathan

    Don’t worry about Dart. It’s not what’s killing Javascript. Coffeescript is. http://www.w2lessons.com/2011/11/coffeescript-means-giving-up-on.html#comment-357300249

  • Rodrigo Moraes

    Coffeescript and Dart have different purposes. Dart also compiles to JavaScript but similarities end here; Dart puts a lot of emphasis on maintainability and toolability. These are the main goals.

  • Anonymous

    I messed around with it as well. I really hope it does catch on, I really love its style, JavaScript makes me sad.

  • http://twitter.com/pragpub Michael Swaine

    I think you’re right about not betting against JavaScript. I’d say that Dart and CoffeeScript expand the JavaScript ecosystem. (FWIW, I edited a book on CoffeeScript and am currently editing one on Dart.)

  • http://twitter.com/iamwarry Warry

    90′ = HTML + CSS + JS = DHTML ~~ ie6
    00′ = HTML + CSS + JS = AJAX ~~ Firefox
    10′ = HTML + CSS + JS = HTML5 ~~ Webkit

    One constant…

  • http://profiles.google.com/boomras Boom Ras

    Javascript is not a language intended for building complex applications. It is a simple scripting language to make thinks like bouncing balls and goofy $#!t like that. The reason it has become so popular is that even a dunce can make something happen with it, and that is good thing. However, those same people in turn now start strutting around like their experts in programming because they know one silly and pathetically simple language.

    This is why Google created dart, They where sick and tired of having their engineers mess around with the mess that is Javascript. Google’s intention is indeed to replace Javascript with a much better faster alternative. Javascript will still exists, but will be relegated back to it’s secondary role status at best.

    As for browser support, Google can make it available through the browser on android, Apple will probably reject it ( but what else is new ) and for all other platforms I don’t see why it won’t be distributed as a Google branded plugin. Google has a very positive brand image (unlike Adobe) and will gain the trust of people real easy. Sure the basement tech bloggers will moan and complain about web standards, but who cares what they think, no one ever has and no one ever will. It’s all about the user/customers and if Google can deliver a much better web experience through the Dart plugin, than Javascript days are numbered. I for one say good riddance.

  • http://profiles.google.com/boomras Boom Ras

    Yea, that Javascript was, is and will always be horrible to work with and for people who are two lazy(or not bright enough) to learn a real language.

  • http://profiles.google.com/boomras Boom Ras

    Not too mention the fact that the end goal for dart is to produced code that resembles jitted byte code and not the interpreted AST(slow!!!!!!!) used in Javascript.

  • http://profiles.google.com/boomras Boom Ras

    Oh and your footnote about the ECMAScript group is just hillarious!! Terrific work?? Really? In what planet do you even consider that even work! The ECMAScript group is like the gang that can’t shoot straight. Pathetic, doesn’t even begin to describe the people involved with this group. Everyone in the universe knows that!!! Javascript 2.0 should have been hear a years ago but we are still waiting and there is no indication that it will happen anytime soon. I really don’t understand your logic but then again that Kool-Aid must be really REALLY good!

  • Anonymous

    Judging by your use of the word two, I am guessing English isn’t a real language.

  • pritam roy

    its a shame that self professed programmer bigwigs frown upon javascript usage and differentiate scripting from “programming” .
    You only need to see the wonderful applications built in the so called scripting languages to see how far scripting languages like javascript and php have come

  • http://pulse.yahoo.com/_EZJFG62KC67U5LONM4DICXEUVY Dave

    mm. Only of course, with CoffeeScript, rather than introducing a lexically scoped let expression, they opted for a curious rule- if a function contains a variable reference with the same name as a variable in outer scope- then the identifier references the outer variable, otherwise it’s a local variable.

    What this results in is a language where you cannot say anything about a snippet of code without reference to the *entire program*. CoffeeScript works fine for short and simple code, but they fundamentally screwed up the language on that single point. Completely failed programming language theory, did not attend class, did not even open the textbook. You can’t maintain large software in a language like this, which is why no other language in use today works like that (including JavaScript). Sorry, them’s the breaks, which is a pity, because it *does* have some really nice ideas in it and I really wanted to use it, and was willing to overlook some of the mind-bendingly fluffy offside rule mangling that occurs between the lexical analyser and parser.