Microsoft Announces TypeScript: Will It Change The Web?

Posted in Coding, JS & AJAX, News, Web Design2 years ago • Written by 10 Comments

Like it or not, JavaScript has long established itself as a de-facto scripting language on the web. There are many programmers who are in love with JavaScript, and then there is an equal number of programmers who hate it. Yet, if you are developing for the web, you most probably deal with JavaScript in some way or another, at some point or the other.

Owing to such popularity, JavaScript has seen its fair share of clones copies languages that attempt to replace or build upon JS. CoffeeScript is a shining example, for instance.

Among such examples, we recently saw a new entrant few days ago. Yes, Microsoft announced the release of TypeScript, a typed superset of JavaScript.

What is it all about? Read on as we take a look at it in this article!

TypeScript: An Introduction

So, what exactly is TypeScript? As it becomes clear, TypeScript is a language for application-level JavaScript development. It is based on JavaScript, complies to JavaScript, but is better than JavaScript (or at least that’s what folks at Microsoft want us to believe).

Basically, in its purest form, JavaScript lacks certain features that are otherwise common: for example, in-built module system and static type checking aren’t present in JavaScript. TypeScript wishes to build upon these very areas.

Certain noteworthy features include:

  1. Class declarations
  2. Support for modules
  3. Optional static typing
  4. Visual Studio plugin

The language is scalable and open source and comes with an Apache 2.0 license. Another shocking point, isn’t it? Microsoft hasn’t been known for its open source ventures ever. In fact, its products such as Windows and IE often receive the maximum amount of hatred from the open source community.

TypeScript: The Reasons

Why exactly did Microsoft feel the need for launching TypeScript? This is one question that only MS can answer. We shall, however, try our best to figure it out.

Google already had come up with its own answer to the problems related to JavaScript in the form of Google Dart. Couldn’t MS simply back Dart and support it, rather than wasting its time and energy on a new language? Probably not. Firstly, MS will not bother backing its rival Google’s creation. Secondly, Dart is known for exhibiting a radical departure from JavaScript (to the extent that many feel Dart aims to replace JavaScript altogether). Naturally, if Microsoft were to address the JavaScript user base, going with Dart wouldn’t have helped.

However, one wonders, if Dart was not serving the purpose, why wasn’t CoffeeScript considered? Also, on a related note, did JavaScript really need stuff such as static typing?

However, business and opinion questions apart, Microsoft does indeed have a practical interest in JavaScript. First up, both Bing Maps and MS Office Web Apps have something or the other to do with JavaScript, and the development teams for both these products have had their share of confusion with it. In fact, it is this very practical need — the upcoming projects’ reliance on JavaScript — that led to Microsoft’s interests in TypeScript development.

Furthermore, with the desktop OS being replaced by the internet OS (read: Windows no longer a dominant monopoly), Microsoft at least wishes to present Visual Studio as a legit entity, and offering an open source TypeScript with some added awesomeness is both a smart and noble (clever?) move.

TypeScript: The Details

Basically, TypeScript is a super set of JavaScript: you can write JS code within TS, and no one will declare you guilty. That said, as mentioned above, TypeScript offers additional goodness and features that are otherwise lacking in JavaScript. Unlike Dart, TypeScript does not provide you with new syntax rules: it accepts all that is good in JavaScript, and offers certain newer additions of its own.

For the sake of simplicity, we shall take a look at the simple case of type inference in TypeaScript. If you declare something like this:

var c = 100;
var me = “awesome”;

TypeScript will automatically infer that the former variable holds a numerical value, whereas the latter is a string type.

TypeScript also supports classes with the optional type annotations integration:


class Person {
private name: string;
private age: number;
constructor(name: string, age: number) {
this.name = name;
this.age = age;
}
toString(): string {
return this.name + " (" + this.age + ")";
}
}

Code Courtesy: Wikimedia Commons

The language comes with support for features proposed in the upcoming ECMAScript 6 standards.

Wish to learn more about TypeScript? You can master it using the specifications’ file here.

Note: Above link directs to downloadable DOC file.

Conclusion

So, is TypeScript worth it? In a scenario in which the internet is, to a good extent, powered by JavaScript, Microsoft has tried to augment JS and its features and couple them with a creation of its own in the form of TypeScript. The plan in itself is good, and though it has so far received a mixed reaction, it is pre-mature to declare it a success or failure straight away. I’m happy that the language is open source, and unlike others, it is not refusing to acknowledge that it comes from JavaScript.

What do you think of TypeScript? Will you be using it? Share your thoughts with us in the comments!

Related Links

If you enjoyed this article, get email updates (it's free).

Join over 77,235 Subscribers Today.

35 Written ArticlesWebsiteGoogle+

Sufyan bin Uzayr is a freelance writer and artist. He writes for several print magazines as well as technology blogs, and has also authored a book named Sufism: A Brief History. His primary areas of interest include open source, mobile development, web CMS and vector art. He is also the Founder and Editor-in-Chief of an e-journal named Brave New World. You can visit his website, follow him on Twitter or friend him on Facebook and Google+.

10 Comments Best Comments First
  • Ed Charbeneau

    Friday, October 19th, 2012 09:25

    1

    Excellent write up. I for one plan to learn TypeScript soon. It’s nice to see the power of Visual Studio finally being used in conjunction with JavaScript.

    0
    • Sufyan

      Friday, October 19th, 2012 12:41

      2

      Hey! Yes indeed, I’m also looking forward to the impact TypeScript has, and I’ve already started experimenting with it. With the added goodies like static typing, it seems more “my kinda” language now, as compared to JS. :)

      0
  • JHawes

    Friday, October 19th, 2012 16:26

    3

    Microsoft continues to surprise me in out detached a major corporation can become from their market. They continue to put tons of money into IE 9 while not supporting simple new CSS3 features. ASP was more of less a rip-off of PHP, and this is just an attempt to compete against something they really don’t need to be competing with. It reminds me of how Apple recently detached themselves from Google maps since Google was a competitor – Google will never be like Apple, why fight over these little things. If competitors let each other take their niches and simply compete at what they’re good at this nonsense might not be occurring. This is all the business side of me talking though, I may be missing something here possibly.

    0
    • Sufyan

      Saturday, October 20th, 2012 03:39

      4

      “just an attempt to compete against something they really don’t need to be competing with.”
      –Yes, if they are trying to compete against JS, I agree with you 100%. However, if MS is indeed keen on using static typing and class modules along with JS, then TypeScript might not be a bad innovation after all.
      Time will tell us about their real motive: business competition or mere improvisation. :)

      0
  • John

    Saturday, October 20th, 2012 11:48

    5

    Did you know that JavaScript++ and JSX, which also extend JavaScript, existed long before TypeScript? So why is MS reinventing the wheel?
    But if you decide to use TypeScript, you can simply include it in a HTML page, just as JavaScript, thank to TypeScript Compile: http://bit.ly/RKCykc

    0
    • Sufyan

      Sunday, October 21st, 2012 13:00

      8

      Thanks for sharing the info about the tool.

      0
  • Martijn

    Saturday, October 20th, 2012 14:18

    6

    It will succeed about as much as Dart did.

    Sticking to Javascript, thank you.

    0
    • Sufyan

      Sunday, October 21st, 2012 12:59

      7

      LOL…thanks for sharing your opinion. :)

      0
  • Prijm

    Tuesday, November 13th, 2012 21:58

    10

    yeah its great.. i think its not a javascript alternate is a javascript modified version … so on :)

    0
  • Bless Quarshie

    Sunday, October 21st, 2012 18:32

    9

    Changing the web? Not very likely.
    MS with respect to web standards are being very lax. IE is still a pain in the neck to work with, talking about standards-compliance (in spite of version 9), and well, they may have put some innovation into TypeScript – maybe things that JS should have had by now – classes for one – so perhaps there is a little innovation there.
    But for me, that’s just about it. I really don’t think TypeScript will be making too much waves. That it’s available as a plugin for Visual Studio is also an interesting thought; that might be what fuels the widespread use of it. Open source? Hm, MS what are you up to?

    0
  • Prijm

    Tuesday, November 13th, 2012 21:58

    10

    yeah its great.. i think its not a javascript alternate is a javascript modified version … so on :)

    0
  • Bless Quarshie

    Sunday, October 21st, 2012 18:32

    9

    Changing the web? Not very likely.
    MS with respect to web standards are being very lax. IE is still a pain in the neck to work with, talking about standards-compliance (in spite of version 9), and well, they may have put some innovation into TypeScript – maybe things that JS should have had by now – classes for one – so perhaps there is a little innovation there.
    But for me, that’s just about it. I really don’t think TypeScript will be making too much waves. That it’s available as a plugin for Visual Studio is also an interesting thought; that might be what fuels the widespread use of it. Open source? Hm, MS what are you up to?

    0
  • Martijn

    Saturday, October 20th, 2012 14:18

    6

    It will succeed about as much as Dart did.

    Sticking to Javascript, thank you.

    0
    • Sufyan

      Sunday, October 21st, 2012 12:59

      7

      LOL…thanks for sharing your opinion. :)

      0
  • John

    Saturday, October 20th, 2012 11:48

    5

    Did you know that JavaScript++ and JSX, which also extend JavaScript, existed long before TypeScript? So why is MS reinventing the wheel?
    But if you decide to use TypeScript, you can simply include it in a HTML page, just as JavaScript, thank to TypeScript Compile: http://bit.ly/RKCykc

    0
    • Sufyan

      Sunday, October 21st, 2012 13:00

      8

      Thanks for sharing the info about the tool.

      0
  • JHawes

    Friday, October 19th, 2012 16:26

    3

    Microsoft continues to surprise me in out detached a major corporation can become from their market. They continue to put tons of money into IE 9 while not supporting simple new CSS3 features. ASP was more of less a rip-off of PHP, and this is just an attempt to compete against something they really don’t need to be competing with. It reminds me of how Apple recently detached themselves from Google maps since Google was a competitor – Google will never be like Apple, why fight over these little things. If competitors let each other take their niches and simply compete at what they’re good at this nonsense might not be occurring. This is all the business side of me talking though, I may be missing something here possibly.

    0
    • Sufyan

      Saturday, October 20th, 2012 03:39

      4

      “just an attempt to compete against something they really don’t need to be competing with.”
      –Yes, if they are trying to compete against JS, I agree with you 100%. However, if MS is indeed keen on using static typing and class modules along with JS, then TypeScript might not be a bad innovation after all.
      Time will tell us about their real motive: business competition or mere improvisation. :)

      0
  • Ed Charbeneau

    Friday, October 19th, 2012 09:25

    1

    Excellent write up. I for one plan to learn TypeScript soon. It’s nice to see the power of Visual Studio finally being used in conjunction with JavaScript.

    0
    • Sufyan

      Friday, October 19th, 2012 12:41

      2

      Hey! Yes indeed, I’m also looking forward to the impact TypeScript has, and I’ve already started experimenting with it. With the added goodies like static typing, it seems more “my kinda” language now, as compared to JS. :)

      0

Comments are closed.

54.204.217.249 - unknown - unknown - US