Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

TypeScript: Industrial-strength JavaScript

Jon Udell | Jan. 20, 2015
The TypeScript language is most succinctly described as an optionally typed superset of JavaScript. Since existing JavaScript is valid TypeScript, you can begin using the TypeScript compiler — and TypeScript-aware tools — by simply changing filename extensions from .js to .ts.

Culture shock

Despite its advantages, TypeScript faces an uphill climb for reasons that are more cultural than technical. Developers prize JavaScript's freedom of expression, and while TypeScript works hard to be unobtrusive, its mission requires developers to voluntarily give up some of that freedom.

The benefits become clear at large scale, but many JavaScript projects aren't operating at that scale. One that is, Mozilla's Shumway, implements a Flash-compatible runtime in more than 170,000 lines of TypeScript. It's easy to appreciate why a project of that size would need industrial-strength type checking. For many projects, though, the need doesn't seem so compelling.

Then there's the Microsoft factor. Its rocky relationship with open Web technologies over the years has left many Web developers with a sour taste that won't easily dissipate.

TypeScript is, objectively, doing everything right. The project is being developed in the open on GitHub, under an Apache 2.0 license, and it accepts community contributions. The vast majority of pull requests are from the GitHub accounts of Microsoft employees on the core team, naturally, but you can also find community-contributed bug fixes. This is not the behavior people have learned to expect from Microsoft, and it will take more than a project like TypeScript to change those expectations.

What has turned some heads is TypeScript's relationship with a couple of other projects with similar goals: Google's AtScript (which is being used to build Angular 2.0) and Facebook's Flow. AtScript is exploring the idea of runtime as well as static type checking, while Flow hopes that aggressive type inference can minimize the need to annotate existing code bases and simplify the use of type checking for new development. Both evaluated TypeScript, and neither adopted it. But everyone agrees that type checking for large-scale JavaScript development is an idea whose time has come. 

More accurate, it's an idea whose time has come back around again. TypeScript's type annotation syntax originated in ECMAScript 4 and was implemented in ActionScript 3, but never landed in the ECMAScript 5 that runs in today's browsers. Type annotations aren't part of the forthcoming ECMAScript 6, but are widely expected to land in the next incarnation of the language. Nobody knows what those annotations will be. But AtScript and Flow are betting that they'll look a lot like the TypeScript syntax, so they're aligning with it.

When JavaScript expert Axel Rauschmayer wrote about TypeScript, AtScript, and Flow on his blog, the first comment was: "Hmm, when Facebook, Google, and Microsoft are working together it kinda looks like future of the Web." It does indeed. That future has been a long time in the making, and will unfold gradually, but the reinforcements we need are on the way.


Previous Page  1  2  3  4 

Sign up for Computerworld eNewsletters.