There is a contingent of programmers who think that JavaScript just isn’t good enough. Most of the members of this group are fans of statically-typed languages like C# or ASNA Visual—languages where the compiler is always the first round of unit testing. In these languages, the compiler imposes strict compile-time checking that keeps your code from assigning a date data type to an integer. Many of these coders react negatively to JavaScript’s loosely typed variables, its lack of a formal class concept, and its dynamic nature (you can easily add methods and properties at runtime!). JavaScript doesn’t care if you assign a date data type to an integer. If you do, that’s on you!

Like JavaScript or not, all programmers agree on one thing: JavaScript is a necessity (and some consider it an evil necessity!). In modern browser-based applications, its use is mandatory. There isn’t another client-based, cross-browser alternative. JavaScript is the common denominator across all browsers—and no amount of whinging or complaining is going to change that. The alternative to JavaScript, then, is to create a “modern” language that compiles to standard JavaScript.

There are a surprising number of such languages that generate JavaScript. Once you’ve used one of these languages to generate 100% box-stock JavaScript, you then deploy that generated JavaScript with your application. The pain of debugging (you’re debugging against the generated code, not the code you wrote!) is considered a rational tradeoff to being able to use statically-typed language features (such as compiler errors).

By way of full disclosure, I have only used one of alternatives below (CoffeeScript) and then only on a small hobby project. I have really come to appreciate JavaScript–in all its natural glory–over the last couple of years and am skeptical of the friction that a JavaScript alternative might offer (especially during debugging). I like plain ol’ JavaScript. I mean really like it. So I don’t generally accept the premise that JavaScript as we know it today is fundamentally flawed. So consider me skeptical, but the concept is gaining traction in the general Web development community.

Here are three notable attempts at making JavaScript better:

  • CoffeeScript. CoffeeScript is the mindshare leader currently amongst JavaScript alternatives. It has a wide following with lots of good documentation and tutorials, and a pretty measure of tooling support from many vendors. Like C, CoffeeScript was written in itself using Node.JS server-side JavaScript (that a compiler can be written in the language it compiles continues to blow my mind!). There are lots of great Internet resources on CoffeeScript and it’s popular enough that there are several third-party CoffeeScript books available. Having played around a little with CoffeeScript, I do understand its appeal. I’m just not sure it’s for me. Given CoffeeScript’s popularity, it’s conceivable that at least some of popular browsers (FireFox especially) will provide intrinsic development support for CoffeeScript.
  • Dart. Dart is Google’s “structured web programming platform.” Where CoffeeScript is a simple and lightweight solution, Dart is nearly (like many things Google) an ecosystem all to itself. It comprises a language, libraries, and an editor. Dart is imposing with, what appears to me to be, lots to learn before you get to anything you can call results. Dart isn’t just a preprocessor, but rather a native virtual machine that interoperates with JavaScript. Given the political nature of Dart, if it takes off, we might get native Dart support in Chrome, but probably not the other browsers. There is at least one third-party book available about Dart.
  • TypeScript. TypeScript is Microsoft’s entry into the fray. TypeScript is a lot more like CoffeeScript than it is Dart. TypeScript is a pet project of Microsoft’s Anders Hejlsberg. Anders was the chief architect behind both Borland’s Delphi and MS’s C#—so he clearly has the language chops to pull off a project like this. Shortly after TypeScript was introduced, it didn’t take too many hours for a bunch of negative comments to surface—many of which seem more motivated by politics than technical issues. Microsoft’s Web Essentials 2012 free download for Visual Studio 2012 provides some interesting support for both TypeScript and CoffeeScript.

If you’re doing Web development (and who isn’t these days?), the concept of an alternative, improved JavaScript is worth watching closely.