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

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

Summary: Anders Hejlsberg, the father of C#, has a new project. But can it win over developers outside of the Microsoft camp?

TOPICS: Windows

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.

Topic: Windows

Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.


Log in or register to join the discussion
  • OO... Why don't we already have it?

    There have been a lot of attempts lately. Google has it in AngularJS, but TypeScript has it with great tooling, and without tooling, it's just another OS project.

    The biggest concern about this is Microsoft! I fully expect to find their grandmother under the bus along with Silverlight!

    Will they stay the course, even when the ride gets bumpy? Who knows, or better yet, who trusts them to do it?
    • Truly Open Source === Vendor Agnosticism

      With a license like Apache 2.0, the community can certainly take this over if MS/Anders bails on it. I'm not really worried about the MS factor here. As long as this project gets a good start, the community can fill the gaps (i.e., Eclipse/other IDE integration, etc.). That's what forking is for, despite what your mind first thought. ;-)
      • Objective-C

        If this BS*script open source basterdization ever takes off or casts shadow over C# I am switching to Objective-C for good.
  • C# is for fools

    VB was a more powerful language 15 years ago.. than C# + Javascript today.
    Why is he going back trying to reinvent the wheel again?

    Microsoft should STFU and take COM / VB seriously!
    Aaron Kempf
    • LOL!!!!

      I hope thats a joke... LOL... too funny
    • Modern VB is a great language

      On par with C#. The syntax isn't quite as elegant, but it's at least as powerful as C#. It's a bit nicer for doing dynamic programming than C# is.

      But, of course, I cut my teeth on C and C++; VB is still somewhat foreign to me (when people read any VB I write, they can tell I grew up in the land of squiggely brackets and semi-colons).
      • yep great...

        Since they both came from MS, through the years they have been taking a lot from each other. Bringing the "good" things one have to the other and also adding some Phyt...

        oops. :)
      • Absolutely

        I built a ton of business apps using VB and 90% of them are still out there doing their thing 10 years down the road. Couldn't be beat for fast and inexpensive development. It's just the code snobs who couldn't/wouldn't recognize VB as a great development tool.
        • Absolutely

          I Absolutely agree to this. Think of a company which did lots of investments in creating their COM tool over the years for VB or any COM complient Lang. All the efforts went in vein.
      • VB

        I agree, VB is a great language and far more powerfull than people give it credit. As for the comments I have read about MS being so good, it is still a poor operating system. Right now, if you could get the drives, you could put OS2 4 on a machine (it came out before Win 95) and it would blow win 7 away. It made true virtual machines, it created virtual working platforms for each program if desired, it did things that Win 7 still does not do. If Bill would not had lied and boasted about Windows so much we may have all been running an OS that would be handreds of times more powerful.
        • OS2 Warp was great for users

          It was a really elegant GUI and was easy for the user to get involved. I ran AutoCAD 10(?) in an OS2 DOS box and it was 25-30% faster than MS-DOS.
    • Very True

      May be lets put it this way,
      over the years companies gathered a lot of toolsets, ActiveX components and interfaces which makes VB powerful and not the core VB as C# probably outsmart VB if you compare the core.

      True that microsoft has completely abandonment COM and marooned small companies which relied on it and lots of investments.
    • VB and VB.NET

      VB was a complete disaster. I remember that Delphi version 1 (created at Borland by the same Anders Hejlsberg) already was beautiful fully object-oriented language, while VB was still a full mess, a Big Ball of Mud.
      VB.NET is a completely different story. It's basically a C# dressed into an ugly cloth of VB syntax. It's almost as powerful as C#, but no one programs in it any more and I don't see any reason to use this artificial hybrid when we have a beautiful C# - which became even more beautiful when it got functional features (lambda expressions, LINQ, etc.)

      I'm kind of skeptical on attempts to generate JavaScript from object-oriented languages like Java, C#, or Scala. JavaScript has different ideology behind it - inheritance through prototypes. Douglas Crockford explains it in a best possible way
      • CoffeeScript is an exception

        Dean Wampler said in a comment for "Scala to JavaScript compilation effective?" post on StackOverflow at,
        "I've never found these "language X to JavaScript" tools to be worth using. Debugging, quality of code generation, interfacing and using native JS libraries, etc., etc. mostly get compromised. CoffeeScript is an exception, because it is a new syntax for JavaScript, not an entirely separate and unrelated language.
        If you need to use JS (or another language for that matter), embrace it and learn it." 
    • You are stuck with old habits

      Sorry sir but you seems to know the old stuffs you learnt the 1st time. Do you know the power of polymorphism that we can do with object oriented language? Probably you cannot even imagine that what it could be. Programmers who know well several languages will tell you that VB is a joke. Java, C#, Android programming is also based on Java syntax. They have this kind of syntax because it is an efficient style. VB is too verbose and ends up with clumsy construct. Spend a few months to learn C# courageously and you'll forget about VB.

      That reminds me a conversation I overheard last year during a Sharepoint 2010 session. Two old chaps complained that SQL is too clumsy they could do the same using Clipper in no time (an 198x compiled language of dBase3). Morality: when you don't accept that you are a dinosaur, you tend to self-congratulate in consolation.
      • You are stuck with incorrect assumptions

        I know several languages and I see Java and Android is pretty much a joke.
    • seriously??

      Average salary of C# developers is $91K in the U.S. I don't think anyone doing C# for a living can be considered a fool. You can get on any soapbox you like and say how awful c# is "in YOUR opinion" but nobody making that kind of money would care.
  • mixed feelings so far

    First, I'll admit that I haven't looked closely at TypeScript yet. It does have tremendous potential. And second, I'll start from a perspective of another C# fan - after seven years of C# and .NET development, I'm still often astonished at its depth and versatility. It's great to see Anders extending his reach into yet another domain.

    My first concern, though, is that JavaScript is not an OO language. It can be done, and done well, but it always feels like bending the paradigm. JS began as a sort of "scriptlet" language that could be used to decorate bits of HTML markup. This role of augmenting markup hasn't gone away; it has become more central to JavaScript's role than ever.

    If JavaScript adheres to any particular paradigm, it's more functional than OO. JQuery has really moved the language in that direction over the last several years. That shouldn't be an obstacle for TypeScript, though; C# has evolved its own powerful functional tools, including LINQ, generic delegates, event handlers, tasks, and its new asynchronous programming model. Anders Hejlsberg has led all of this evolution of C#, and I have no doubt that these aspects of C# will inform the development of TypeScript as well.

    My second reservation is based simply on the range of quality of existing JavaScript code. There are certainly many outstanding JavaScript developers, but there are also many horrifyingly bad ones, who know and care nothing about OO or any other paradigm. Along with this is the problem of legacy code. TypeScript as a language is not enough. It has to integrate well with test frameworks and a practical knowledge base for working with legacy applications.

    The tooling issue leaves me wondering what Microsoft can bring to the table that's really new. Visual Studio, especially when enhanced with the ReSharper plugin or equivalent tools such as Telerik's JustCode, is already the best development environment for JavaScript that I know of. That includes Intellisense, auto-completion, refactoring support, and extensive support for code cleanup of common problems such as unused or uninitialized variables, scope issues, missing semicolons, dead or unreachable code, etc. So, really, what's going to be new and different beyond strong typing?

    Syntactically and structurally, can TypeScript take us the next steps beyond Doug Crockford's distillation of JavaScript's "good parts"?
    diane wilson
    • What is the added value of TypeScript?

      I have mixed feeling about TypeScript too. It looks nicer and cleaner than Javascript code, but I doubt if it adds anything but syntactical sugar. Drawbacks of the language are introduction of another language, reduction of Javascripts prototypal inheritance to standard OO, and introduction of a compile step over your code.

      Javascript by itself is very flexible and unstructured, it is easy to create a mess with it. You really need tooling and frameworks to keep your Javascript projects structured and maintainable. Things I really need when working on larger Javascript projects:

      - Debugging tools.
      - Package management.
      - Libraries and frameworks to keep the code structured and manageble.
      - Type annotation & code documentation. When working on larger projects with more people, one of the things I indeed miss in Javascript itself is variable type annotation. The things you typically like about strict typed languages: the ide/compiler warns you about improper method calls like wrong parameter types, helps overloading required functionality from super classes, interfaces, etc.

      Point is, the tooling for this is already there, and is getting better and better:

      - Browsers have better and better debugging tools, and debugging gets implemented more and more in IDE's.
      - We have NPM for package management, very easy, works great.
      - There are great MVC frameworks out there, and great libraries such as jQuery, making it easier to create larger projects and reuse common functionality.
      - Variable typing can be solved using annotations. This serves two purposes: IDE's can utilize these annotations for code inspection, and it encourages you to document your code. This also keeps the variable typing at an optional, supportive, "meta" level, instead of requiring a new language for that.

      Have a look at the WebStorm Javascript IDE. It comes with type checking (using jsdoc style annotations), code inspection, auto completion, debugging, and comes integrated with github and node.js, etc. It is really amazing and brings Javascript programming to a whole new level.

      Anyway, leaves the question open to me what TypeScript really adds besides syntactical sugar.
      • syntactic sugar: tastes great!

        Let's not downplay the usefulness of syntactic sugar. If it makes code easier to write, easier to read, and less error-prone, then it's certainly worth having. (See, for example, the async and await keywords in C# 5; they don't actually add any functionality, because they compile down to the task async model introduced in .NET 4. But the clarity they bring to async programming is extremely valuable.)

        I'd much rather have strong typing than annotations; to me, that is not "syntactic sugar." Strong typing enforces good practices; annotations do not. (And annotations, like all comments, can lie.)
        diane wilson