Microsoft TypeScript: “Syntactic Sugar” For JavaScript


By

Are you involved in application-level development using JavaScript? If so, this news might interest you!

A few weeks ago, Microsoft unveiled a new JavaScript-like programming language named TypeScript. At its most basic level, TypeScript operates by translating code into JavaScript (which enables its apps to run in any browser). The language itself is pretty similar to JavaScript in terms of its syntax but with a good set of additions of its own, such as optional static typing, among other things.

TypeScript

Dubbed as a typed superset of JavaScript, TypeScript compiles to plain JavaScript, thereby enabling you to use the well-known JavaScript syntax and semantics for building your apps. Wish to build large apps? TypeScript comes with all the tools you need — classes, modules and interfaces!

In the words of Microsoft, “TypeScript is syntactic sugar for JavaScript.”

Sounds fun? Need a demo? Let’s take, for example, the extensive use of type inference in the language. If you type the following line of code: var j=0;.

TypeScript will figure out that the variable’ j’ has the type number. Similarly, if you type the following:

function i()
  {
  return "awesome";
  }

TypeScript will infer that the function i() has the return type string.

So, what does TypeScript bring to the table? Apart from optional static typing, we also get class declarations, support for modules, and a Visual Studio Plugin. The language itself is active on Codeplex and comes with an Apache 2.0 open-source license.

You can find out more about the TypeScript project by visiting the homepage or simply grabbing hold of the specifications’ PDF or the source code.

What do you think of TypeScript? Another language in the pool of programming languages? Or a much-needed innovation, trying to address the issues raised by Dart, but simultaneously adhering to JavaScript? Have your say in the comments below!

Related Topics


Top
This page may contain affiliate links. At no extra cost to you, we may earn a commission from any purchase via the links on our site. You can read our Disclosure Policy at any time.