Microsoft TypeScript: Can the father of C# save us from the tyranny of JavaScript?

Anders Hejlsberg, the father of C#, has a new project. But can it win over developers outside of the Microsoft camp?
Written by Matt Baxter-Reynolds, Contributor

I'm not a great one for heroes, but the few I do have includes Anders Hejlsberg. He's the architect of C#, a technology that I've used virtually every day in the past eleven years of my career as a professional software developer. It's the technology that's touched my life the most, enabling me to get a deep sense of personal satisfaction out of my job and career. I wouldn't be surprised if other software developers who work day-in-day out with C# feel the same fondness for it as I do for it.

C# and .NET were hugely important for Microsoft. Back in 2001, the developer story on Windows was an utter mess. An almost indescribable hodgepodge of messy hacks and broken approaches. C# and .NET created a staging post for those targeting the Microsoft stack to gather and regroup before heading off on a journey that on aggregate measures in millions of man-years across the community as a whole. Collectively, we gathered, we changed direction, and all set out together.

But with TypeScript the world is very different. This isn't one man's vision of how to change the products of one company with the objective of selling more of that one company's product. This is about how to change JavaScript - a tool that reaches way outside of Microsoft's sphere of influence and into the heart of the open development community.


It's commonly regarded - perhaps by people who don't know the language well - that JavaScript's object-orientation story is lacking. Approaching a JavaScript activity with the intention of applying OO thinking is a good way of getting your heart broken. 

From first principles, OO is attractive because if you're trying to build a complex system it's easier in terms of mapping requirements into work items, structuring code, sharing work out in large teams, surfacing meaning during maintenance, and so on. If you want to do complex work, you don't want to use JavaScript.

Or so you'd think. The reality is that JavaScript seems to bend and flex this logic almost as if rather than being developed by humans thinking human thoughts, it was accidentally left behind by visiting aliens. People do manage build amazingly complex things with JavaScript despite its total lack of sympathy for OO. Its inherent flexibility makes it work even when you think it can't possible.

So how does TypeScript work? All you have to understand for this article (and I'll do another that looks into the mechanics) is that TypeScript is a superset of JavaScript that lets developers add strong-typing and OO. It's designed to be very sympathetic to JavaScript - there's no attempt to replace, or subsume the language. It's not an "extend, embrace, and extinguish" strategy. It's solely designed to move the story on.

At its most basic, it's just "syntactic sugar". Sprinkle it onto common or garden JavaScript and you'll get code that's easier to read and easier to work with on larger projects.

What you also get is IntelliSense. Having spent today working on a PhoneGap project with a basic text editor and no IntelliSense I'm reminded that building complex code without it is irritating at best, unproductive and costly at worst.

So back to Anders. Let's look at three of his home runs. Firstly Turbo Pascal, the one in which he takes Pascal and reinvents it to make it work really well and have developers fall in love with it. Then Delphi, the one in which he takes Visual Basic and reinvents it to make it work really well and have developers fall in love with it. Then C# … you get the idea.

Anders's gift is in looking at where developers are, seeing where they need to get to, and then building a tool that lets them get there. TypeScript is his vision that says where JavaScript developers today isn't a happy place, and goes on to say that their happy place is where decent OO tooling lies.

The challenge

TypeScript will live or die in the open source community. (This isn't 2002.) To that end, I reached out to Miguel de Icaza, an individual with open source chops like few others.

First thing he reflected on was that out-of-the-box what was released today works on OS X. (You can install it in Node.js using the Node Package Manager.) He also went on to talk about how it's open source (it uses the Apache License 2.0). Engagement is also good - the language specification (PDF) is online, and there are managed forums. The initiative is being done entirely in the community, for the community.

In our conversation Miguel told me that "the language architect needs to play an active role". This is one of the things I'm worried about with Anders - rightly or wrongly he's spent a lot of time doing deep thinking within an organisation that's mostly closed-source. (Incidentally Miguel was confident that a mindset adjustment to being more open wouldn't be a problem.) However, I'm going to need to see Anders come out on Twitter and really start communicating as well as all the Microsoft people who are on Twitter do.

Miguel he cited concerns as to whether the "existing JavaScript community is ready to embrace component-based systems". So it's this idea that if OO is so important in JavaScript, why doesn't it exist yet?

On that same topic, Miguel said that "successful open source projects are ones that fill a need". Again, why is OO not in JavaScript already? If it's needed, why has an existing open source project not filled the gap?

I should say that Miguel was general positive about the project, he mentioned only one misstep which was that "the web developers of the world got half the benefits". And I think this is a pretty big misstep. If you're building web apps that run on anything other than Windows, you're likely using a Mac and most likely not using Visual Studio. You need the Visual Studio plug-in to get the IntelliSense. All you get without Visual Studio is the strong-typing. You don't get the productivity benefits you get from IntelliSense.


If it was anyone other than Anders Hejlsberg doing this, I wouldn't even have bothered to write this article. He gives it credibility. The basic open source execution steps are all there - license, source code, willingness to discuss, multiple platforms - tick, tick, tick, tick. The lack of IntelliSense on non-Microsoft tools is an error, and it would have been easy enough to add these to Eclipse and other IDEs.

But this single question remains - if object-orientation in JavaScript is so important, why don't we already have it? It's not like JavaScript is a peculiar, niche thing.

What do you think? Post a comment, or talk to me on Twitter: @mbrit.

Editorial standards