Who knew that when Brendan Eich knuckled down in 1995 for 10 days to create the programming language that would be eventually known as JavaScript, it would be going strong nearly 20 years later? ECMAScript, the official standard behind the open-source JavaScript, is now inching toward version 6. To be drafted in 2013 and possibly completed in 2014, the update will provide the language with some much-needed structure supporting its current usage in increasingly large-scale projects.

But even as Mozilla leads the ECMAScript charge, Microsoft, Google and many others are scrambling to leap-frog the effort with tooling of their own. Finally, in another twist, the Apple/Google mobile battles have made HTML5 and JavaScript running on Firefox (or eventually on Mozilla’s proposed Firefox OS) a viable alternative to iOS and Android.

“JavaScript and HTML are the top platforms available for mobile Web today,” said Luke Hoban, principal program manager for the TypeScript programming language that brings structure to JavaScript development but compiles down to pure JavaScript. An ECMAScript committee member, Hoban is bullish on the mobile  Web: “JavaScript and HTML5 are first-class development languages in Windows 8.”

JavaScript: What’s missing?
It seems that since the early days, there has been debate over the utility and power of JavaScript. “JavaScript: The Good Parts” is Douglas Crockford’s tome pointing the way toward performant code. Some pointed fingers at the Web development community, noting that client-side or Web UI JavaScript programmers were often less educated in computer science arcana than their server-based brethren. And everyone noted that JavaScript would have never lasted this long if it weren’t for its ubiquity, with its virtual machine included in all major browsers thanks to its Netscape birthright.

“JavaScript has become probably the most important programming language in the world,” said Crockford at a 2009 Google Tech Talk. “There’s more JavaScript processors on more computers than anything else by a very large factor. But despite that, JavaScript is not held in very high esteem, even in its own developer community.” He also called it “the world’s most misunderstood programming language” and the “virtual machine for the world.”

Crockford may have been right, however, when he described it as a language that people didn’t feel the need to learn before beginning to program with it.

Even if JavaScript was dashed out too quickly by Eich, as Crockford contended, it contains elegant concepts that reveal its four main influences: Self (prototypal inheritance, dynamic objects), Scheme (lambda, loose typing), Java (syntax, conventions) and Perl (regular expressions). And ultimately it succeeded at client-side code, where Java had failed abjectly with applets.

But cross-site scripting attacks are made possible by a JavaScript design choice: global variables. The language also lacks the organizational concepts that make large codebases with many contributors manageable: static types, classes and modules.
Coming to ECMAScript… eventually
The module declaration is perhaps the most popular improvement coming to ECMAScript 6. With it, a block of code can be encapsulated inline or externally. Classes are also coming, though in the form of syntactic sugar intended to make code more readable, not turn it into Java, according to Google Chrome developer and ECMAScript standards committee member Alex Russell.

“What you should take away from this isn’t that we’re turning JS into Java, it’s that we’re making it easier to read, and that’s all,” he blogged. “Once more for effect: What class means in [ECMAScript 6] is function. Or at least one of the things you currently do with function.” Most importantly, these classes don’t imply a strict type system like Java’s.

In addition, there are new functions, such as Object.observe, which allows any piece of code to be notified if a property changes on a JavaScript object. This behavior can already be found in AngularJS, a popular JavaScript framework maintained by Google. Other features include default parameter values, block scoping, maps, sets, proxies and other API improvements.

Standards bodies ratify at the speed of sedimentation, but some of the changes proposed in the ECMAScript spec are already finding their way into browsers—and tools.

TypeScript enables static typing
Thanks to its ubiquity, the explosion of libraries and frameworks has simultaneously made the JavaScript developer’s life easier and harder. And then there are the overlay languages. Perhaps speaking to Crockford’s observation that JavaScript has been historically misunderstood and underappreciated, there has been more than one attempt to displace the language or to abstract it. TypeScript goes for the latter.

“One of the trends that we see at Microsoft is that JavaScript is being used for larger and more sophisticated software, from traditional client apps to heavily server-driven ones,” said Hoban. “Apps are becoming a lot richer on the client. That’s been made possible by faster JavaScript engines and new capabilities along with HTML5, leading to more complex apps. One of the remaining pain points has been the JavaScript developer experience.”

He pointed to teams inside Microsoft developing enterprise-scale, 100,000-line JavaScript apps for Bing Maps and the Office Web Apps as a sign of the need for more robust IDEs and the ability to navigate large, collaborative codebases. TypeScript is a strict superset of JavaScript that adds some of the proposed ECMAScript 6 features, while still compiling down to plain JavaScript.

According to Microsoft Technical Fellow Anders Hejlsberg, lead architect of C#, “Static typing is one of those things that have powered the IDE revolution over the past decade; things like code completion, refactoring, code definition, navigation in large codebases. It’s all powered by static typing,” he said in an October 2012 conference presentation introducing TypeScript with Hoban.

Microsoft has made one thing clear: TypeScript won’t break ECMAScript compatibility. “There is definitely a lot of benefit to ECMAScript 6,” said Hoban. “But it takes time for the standards process to evolve. We take some of those capabilities and bring them to developers today, and also add static typing, which is a more unique part of the value proposition.”

A core philosophy of the TypeScript language, however, is that the static types that a developer adds for more robust, maintainable code are completely erased at compile time, Hoban explained. “When you use them, you get all these benefits at development time, but no artifacts left behind so the performance of the code will match your expectations.”

The language is open source, as is the compiler. The upcoming 0.9 version will include oft-requested generics, overload on constants and compiler tuning. There are additional productivity enhancements for interfacing with third-party libraries such as jQuery, MooTools and Dojo. JavaScript IDEs such as Cloud9 and WebStorm are already supporting the language, and text-editor support for Sublime Text, Emacs and Vim is available.
Dart and the JavaScript ecosystem
Google, albeit unintentionally, made its ambitions clear. In a leaked 2010 memo by Google researcher Mark Miller, he wrote:

“JavaScript has fundamental flaws that cannot be fixed merely by evolving the language. We’ll adopt a two-pronged strategy for the future of JavaScript:

“Harmony (low risk/low reward): continue working in conjunction with TC39 (the ECMAScript standards body) to evolve JavaScript.

“Dash (high risk/high reward): Develop a new language (called Dash) that aims to maintain the dynamic nature of JavaScript but has a better performance profile and is amenable to tooling for large projects. Push for Dash to become an open standard and be adopted by other browsers. Developers using Dash tooling will be able to use a cross-compiler to target JavaScript for browsers that do not support Dash natively.”

Though his point that Google’s complex Web apps were stifled by JavaScript may have been a genuine expression of frustration, the stated intent did not sit well with JavaScript developers. Since that misstep, Google has renamed the language Dart and has avoided repeating the ambition that it should replace JavaScript. But Dart does take a fundamentally different approach than TypeScript, defining its own VM and language (though it can be compiled to JavaScript as well).

“Dart’s much more than a language,” said Seth Ladd, a Web engineer and Chrome developer advocate at Google, in an interview with FLOSS Weekly. “It’s a comprehensive, batteries-included platform to develop for iOS, Android, C++, Java and JavaScript.”

The open-source language is pre-1.0, like TypeScript, and aiming for a 1.0 release in 2013. But the step away from JavaScript makes it feel less viable than Microsoft’s offering. The class-based, dynamically typed, object-oriented language gives structure to Web app engineering via lexical scoping, closures and (like TypeScript) optional static typing. By reminding people that it’s “more than a language,” Ladd might be addressing, too, the oft-lobbed accusation that replacing JavaScript is the lowest of any Web performance geek’s priorities; the bloated Document Object Model (DOM) library, browser compatibility mismatches and server requests are the top bottlenecks.

On its Dart FAQ, Google heads off the concerns: “The Dart project is betting that the language needs some changes, but we also want to improve the DOM and other libraries, and to improve the tools we use. At the same time, Google is also placing bets that JavaScript can be evolved as needed, and [is] contributing to that work. Google wants Web development to be great, and if that happens with JavaScript, we’re happy.” According to Ladd in his interview with FLOSS, “In Dart, we have different semantics.  I think Dart is more ambitious. We add features like getters and setters to the language itself, things like operator overloading and real block scope.”

Out of the box, Dart has a core set of libraries for collections, queues, maps, unit testing (similar to Ruby’s RSpec) and a Web driver library. A headless version of Dartium (a special Chrome build with the Dart VM included) lets developers run programs from the command line. The drone.io continuous integration service also runs the Dart VM “so you get this slick dev cycle right out of the box,” Ladd told FLOSS. Finally, Dart must be written in its own Eclipse-based Dart Editor.
Multicore phones and mature developers
There are compelling signs that JavaScript is not only maturing, but that the Web platform has already shifted to mobile. One of them is the emphasis on tapping into device performance characteristics in ways JavaScript developers never have before.

“…JavaScript [is] entering a completely new and exciting cycle of evolution, innovation and standardization, with new developments such as the Node.js platform, allowing us to use JavaScript on the server-side, and HTML5 APIs to control user media, open up Web sockets for always-on communication, get data on geographical location, and device features such as accelerometers, and more. It is an exciting time to learn JavaScript,” concluded “A Short History of JavaScript” by the World Wide Web Consortium.

“The power is in the browser,” said Ladd. “The pendulum is shifting more to using those multicores in your phone or the 1TB of space on your laptop. For a long time, the Web was not able to take advantage of that.”

Both TypeScript and Dart have concurrent threading built in. Mozilla is aiming to build a browser with “pervasive parallelism.” And Intel Lab’s River Trail project enables Web-app data parallelism: “River Trail gently extends JavaScript with simple deterministic data-parallel constructs that are translated at runtime into a low-level hardware abstraction layer. By leveraging multiple CPU cores and vector instructions, River Trail achieves significant speedup over sequential JavaScript, ” claimed an article on the Intel website.

Languages, such as Dart or TypeScript, are injecting structure into Web programming. Libraries, frameworks and performance- or function-specific JavaScript subsets, such as asm.js, aim to unlock features from the OS and hardware and put that power back into the client. Meanwhile, Web developers are sharing their collective wisdom around JavaScript patterns, highly distributed widgets, enterprise-scale Web apps and elegant JavaScript API development. It seems unlikely, for now, that JavaScript itself will be forgotten anytime soon.