Tuesday, November 22, 2011

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.

0 comments: