English Bulldog with glasses resting head on an open book

Is Microsoft's TypeScript Programming Language Worth the Fuss?

It's been a month since Microsoft announced its new programming language, TypeScript. It seems like now's the time to step back and see whether TypeScript is worth all the fuss and attention that it's received.

In case you've been absorbed in the presidential election in the United States or don't follow every new technology that's emanating from Microsoft, I'm going to give you the quick-and-dirty TypeScript story. If you want to delve deeper into TypeScript, check out the related articles at the end of this article. Here's Microsoft's definition for the new language from the TypeScript website:

TypeScript is a language for application-scale JavaScript development. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open Source.

Catchy, eh? Microsoft's statement boils down to three primary purposes for TypeScript:

  • TypeScript supports large-scale JavaScript development by providing several common code features such as class, interface, and module definitions that make it easier to write a ton of JavaScript code in an application. TypeScript provides a great benefit because JavaScript wasn't originally designed for large-scale application development.
  • TypeScript provides a robust type system for JavaScript. TypeScript formalizes a static type system that describes JavaScript's dynamic types at development time to provide tooling that includes support for refactoring. Although type annotations are optional, they allow type inference and checking during compile time.
  • TypeScript defines a semantic subset of JavaScript.

You can tell that TypeScript is a superset of JavaScript because nearly every snippet of JavaScript code that's lying around already fits the TypeScript definition. You can mix and match your code to build on JavaScript's core to add and implement TypeScript features. You can run TypeScript code through a tsc compiler to create clean and simple JavaScript code that's ECMAScript- compliant and compatible with other JavaScript libraries and tools.

As usual, Microsoft is creating development tools for working with TypeScript. Currently there's a plug-in for TypeScript that's available for Visual Studio 2012. You'll also want to install the latest version of the Web Essentials 2012 extension that's available through Visual Studio's Extensions and Updates feature, which gets you the full range of TypeScript support for Visual Studio.

After you install the plug-in and the extension, the tooling is fairly good for a beta-level product. It provides a new project template, HTML Application with TypeScript, as well as a new item you can add to any project, TypeScript File, which has a .ts file extension by default. Figure 1 shows how the TypeScript designer uses a split screen that lets you edit the TypeScript code on the left and view the generated JavaScript code on the right, which is compiled and updated each time you save the .ts file.

The tools have some flaws but nothing that's too serious. The designer has some basic IntelliSense features and includes support for things such as simple refactoring and jumping to object definitions.

Many of the JavaScript additions provided by TypeScript are features borrowed from the developing ECMAScript 6 standard, and Microsoft is planning to keep its efforts aligned with this emerging standard. One argument for using TypeScript is that you already have a head start on the improvements that are coming to JavaScript in the next version of the ECMAScript standard.

At the very least, TypeScript is an interesting exercise to see what's possible with JavaScript in its current state. In addition, TypeScript provides some nice features for making large-scale JavaScript application development easier. Be sure to grab the Visual Studio 2012 plug-in and the Web Essentials 2012 extension to get the most out of the available TypeScript development tools. TypeScript seems like a promising programming language—one that isn't groundbreaking but that could prove useful.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish