Dart is dead, long live TypeScript

The last story I wrote was about Dart's awesomeness. I have since then changed my mind about it. Yes I have

Dart is dead, long live TypeScript

The last story I wrote was about Dart’s awesomeness. I have since then changed my mind about it. Yes I have.

No, it is not that I think now Dart is not cool, it still is. Just because it offers you reflection it guarantees itself a spot in my programming language hall of fame.

However, I went back to check TypeScript progress recently and I’ve discovered one surprising little thing..

TypeScript doesn’t suck anymore.

Yes, the damage is done. Last time I played around with TS it was in a horrible state. It used to hang visual studio to the point that I had to restart my computer. There was no support for any other editor out there, come on, sublime anybody? Well to be fair, there was a plugin for sublime text, however it was almost as bad as Visual Studio’s support.

Anyway, that is the past, TypeScript is pretty cool now. The compiler is blazing fast, if you use Web Essentials like I do you can open the JS preview pane to see how fast it really is. Or even better go to TypeScript experiments and try the online live compiler.

Ok, so why do I really say that Dart is dead you might wonder? Well the answer is easy, because TypeScript compiles 100% to JavaScript, and it doesn’t require a virtual machine as opposed to Dart, which you can try to compile to plain js as much as you want, but some features just don’t make the cut, like Reflection for example.

On the other hand TypeScript doesn’t offer Reflection, but I can live without it knowing that my code will work in any JS interpreter. The fact that Dart only runs on that Dartium version of chrome is very annoying, and Google is not very open about when exactly the Dart VM is going to make it to the stable version of Chrome, if it ever makes it there.

So too risky to wait to find out, now that TypeScript support is really awesome in Visual Studio, and other IDEs like Sublime and WebStorm, then I can really start using it for real complex web apps.

With TypeScript you can do things like:

module Lerones.Gallego {
    // Is this really an interface?
    export interface IMyself {
        name: string;

    // Whaaa? real classes?
    export class Myself implements IMyself {

        // Private variables
        private _name: string = "";

        constructor(name?: string) {
            // Do we want to do anything in the constructor?
            // the ?: makes the parameter optional
            if (name) {
                this._name = name;

        // Getters and Setters for private variables
        get name(): string { return this._name; }
        set name(value: string) { this._name = value; }

        // Event static functions inside a  non-static class
        static function NewMyself():IMyself {
            return new Myself("Javier Lerones");
            // Return a new instance of this class? 
            // This looks a lot like C#

Well, doesn’t that look awesome? The syntax is so clear is super easy to learn. It actually looks identical to C# except for the module instead of namespace. And you can believe it, this compiles into ES4 JavaScript … well actually you need to target ES5 for that particular class just because of the getter and setter.. that compiles into Object.defineProperty() which is ES5 only.

In any case, I love TypeScript. I think at some point it will replace JavaScript.. probably not.. but it looks like it is going to make creating much more massively complex applications that plain vanilla JavaScript can offer. At least until we get ES6 working on every browser.. but that ain’t happening anytime soon anyway.

Dart is dead. long live TypeScript.