Web Development

Why TypeScript has a chance

Microsoft's typed superset of JavaScript packs a bigger punch than other alternative languages that compile to JavaScript.

Microsoft has decided to bring order to the JavaScript universe. That order takes the form of a typed superset of JavaScript, called TypeScript, which promises to offer JavaScript developers new features, such as proper classes, interfaces, and modules.

TypeScript in Visual Studio.
(Credit: Microsoft)

It's far from a new idea to build a language or framework that improves upon JavaScript.

As the 11th most popular language on GitHub, CoffeeScript is the current leader in the space. With its Ruby and Python influenced syntax and reasonable JavaScript that it outputs, there's a lot to like about CoffeeScript.

But if CoffeeScript isn't your thing, the altjs.org site has an exhaustive list of other JavaScript alternatives.

With so many existing options, why would Microsoft decide to set foot into this arena?

The answer is that it is a simple case of tooling.

The world doesn't need yet another compile to JavaScript language, or another method to bring types into a loose language like JavaScript. But what it does need is a better way to develop the language.

JavaScript is going places, places it was never intended to go.

Lately, whenever a vendor wants to extend its platform with a new language binding, JavaScript seems to popup as the answer. Need a Windows 8 application? Use JavaScript. Want to create a GNOME extension? Use JavaScript.

While development environments and language maturity usually go hand in hand, JavaScript is the exception that proves the rule. The humble JavaScript developer is often left with a toolbox containing a combination of Firebug, various browser development tools, and editor-of-choice autocompletion/IntelliSense plug ins — and the first two options disappear when you get trendy and take JavaScript beyond the browser.

By adding a dash of type structure to JavaScript, TypeScript opens up more inference for editors and IDEs to latch onto — developers that are addicted to IntelliSense are going to love it.

TypeScript's playground: not bad for a text area in a browser.

The fact that TypeScript is a superset of JavaScript should also work in its favour. Whereas CoffeeScript has a different syntax than JavaScript, TypeScript is not that far removed from JavaScript (yet). For developers that are not Ruby syntax aware and do not have large philosophical problems with the way JavaScript behaves, TypeScript gives the ability to add a touch of sanity, while still retaining JavaScript's flexibility when conditions merit it.

TypeScript is released under an Apache licence on Microsoft's CodePlex, but is not yet fully complete — features such as generics are yet to arrive.

It will be interesting to see what TypeScript eventually becomes. Could it become Microsoft's preferred JavaScript? Or will the developer world give it a try and move on?

With language aficionado Anders Hejlsberg leading the charge, it will surely throw up some good concepts and thought bubbles, regardless of whether the language itself gains traction or not.

To give TypeScript a test run, have a quick hack in the TypeScript playground.


Some would say that it is a long way from software engineering to journalism, others would correctly argue that it is a mere 10 metres according to the floor plan.During his first five years with CBS Interactive, Chris started his journalistic advent...


Most of what they have done in TypeScript has been done before. It looks exactly like ES4 from the code snippet shown, and that was a huge failure. The writers sacrificed the strong points of JS in an effort to bring bad parts of other languages into JS. The only real implementation was ActionScript3. To me it looks like MS just said "Hey, lets take ES4 syntax and compile it to ES5". Not exactly ground-breaking in my view. I used to be a lover of strongly-typed languages and had a hard time when I started with JS. But over time I came to realize that forcing typing most of the time was just not all that helpful (it helps the compiler, not the developer). Interfaces are only needed it you have strong-typing. Generics are only needed if you have strong typing. Take away forced types and they are no longer needed. To me, this is another example of trying to fix something that isn't broken, and force Javascript to behave like a preferred language. The driver for this language is the fact that Visual Studio sucks at JS, so they needed a way to change the language to suit their product. If you want to write in a language like C#, write in C#. Also, why say 'promises to offer JavaScript developers new features, such as proper classes' - is this implying that JS does it improperly? Javascript doesn't have classes by design. And personally, I find it much more expressive and easier to work with because of it. Does Javascript have problems? Yes, it does. Is it fundamentally flawed? No. If it were, it wouldn't be so popular. The biggest reason for the recent outcropping of cross-compilers is the fact that developers are lazy and just want JS to work like [insert favorite language here], instead of learning the language.

Deadly Ernest
Deadly Ernest

way too much Javascript on web pages that do NOT need scripts. Too many pages are chock full of little scripts called from all over the Internet because the coders are too lazy to copy them in to the page they're creating, and in most cases all they provide is standard static information that could have been done in basic html with a lot less download; but would require the page designer to know how to write code instead of just steal it.


The fact that it's a superset of Javascript is a big plus. However the killer feature, and I hope they are adding this at some point, would be if they allow you to debug in Typescript rather than Javascript. VS.NET doesn't force me to debug in IL, Delphi doesn't force me to debug in asm, why force me to debug my nicely structured typescript code in a bunch of translated javascript I didn't write. The context shift will give you whiplash.

Deadly Ernest
Deadly Ernest

send back input from the user; otherwise it's a bad design as scripts use more bandwidth and time to download content that could have been done in basic html for less download.


That's not going to change because of this. What might change is that the js that people steal to add to their pages might have less runtime errors :-)

Deadly Ernest
Deadly Ernest

easier to write in javascipt will mean we'll have more websites and web pages using javascript that don't need them - and that is already a major issue. I see the proliferation of the script pages as a big issue because: 1. it increases the download size and time without providing any added benefit when the page does not need script to present static info. 2. it makes it harder to maintain good security due to having to allow the browser to run the scripts at all times.

Editor's Picks