TechHui

Hawaiʻi's Technology Community

A few weeks ago Microsoft released a preview for TypeScript.  What is TypeScript and why would you use it?  Initially TypeScript may look very similar in function to CoffeeScript or Dart.  These are two technologies TypeScript often gets compared to because all three can be used to generate JavaScript.

TypeScript vs CoffeeScript
In function TypeScript has the most similarities with CoffeeScript.  They are both meant to do the same thing: make JavaScript easier to develop.  CoffeeScript simplifies JavaScript by removing a lot of the syntax and making thing simpler.  TypeScript is a superset of JavaScript and tries to make things easier by giving JavaScript more structure, mainly static typing.  If you like Ruby you might like CoffeeScript.  If you like C++/Java/C# TypeScript may be more familiar to you.

TypeScript vs Dart
TypeScript and Dart are similar in that they can both generate JavaScript, but Dart is much more.  Dart is meant to be an alternative to JavaScript with an entirely new language and its own VM with better performance.  One of the use-cases of Dart is to run directly in a browser using a plug-in or even on a server.  TypeScript so far does not have the ability to run directly in anything.  It always gets translated to JavaScript.

Why use TypeScript?
If CoffeeScript, Dart and JavaScript preprocessors can do the same thing as TypeScript then why use TypeScript?  TypeScript was created with tooling in mind.  If you are a developer who has used VS.net or any other IDE you probably know it’s not always easy to develop and debug JavaScript.  That’s why we have all these preprocessors and options in the first place.  By adding static typing annotations and other features in TypeScript Microsoft is attempting to build a way that will allow VS.net to improve the development experience with JavaScript without changing or corrupting the JavaScript language.  With TypeScript it is possible to get more accurate and helpful intellisense/code-completion, error and syntax highlighting during development and still output standard JavaScript code.

One more reason to use TypeScript
Windows 8 is soon to be released to the public.  One of the ways developers can write apps for Windows 8 is with HTML/CSS/JavaScript.  TypeScript was built to help enhance JavaScript tooling support and to also help developers manage larger application scale JavaScript projects.  I would not want to try to write something like Microsoft Word in plain JavaScript, but TypeScript may make a large project more feasible.  I suspect TypeScript was built in part to help developers write and maintain larger JavaScript applications for Windows 8.

I’m looking forward to seeing where TypeScript goes and how it is used.  Although it is open source and works with any technology stack and several IDEs outside of Visual Studio I predict it will mostly be used by Microsoft developers.  As usual it’s not always about which technology is the best, but which you feel the most comfortable with and which fits best for what is needed.  I encourage anyone interested in JavaScript development to take a look and see what it has to offer.

Views: 2267

Comment

You need to be a member of TechHui to add comments!

Join TechHui

Comment by Daniel Leuck on October 25, 2012 at 4:42pm

I've been watching Script# with interest. I'm hoping Microsoft (specifically Anders Hejlsberg) offers assistance in completing full support of the C# 5 syntax. 

Comment by Douglas Ching on October 23, 2012 at 12:28pm

wat

There is a project called Script# that generates JavaScript from C# but it's not officially backed by Microsoft.

Comment by Cameron Souza on October 23, 2012 at 10:54am

@Scott - LOL! The JS expression [ ] + [ ] evals to "". Yuck!

Comment by Scott Murphy on October 23, 2012 at 3:45am

But JavaScript is perfect as is....https://www.destroyallsoftware.com/talks/wat

Comment by Daniel Leuck on October 22, 2012 at 12:08pm

Nice writeup! Scott was just telling me about TypeScript over dinner in Tokyo last week. In looking at the language I see a lot of ideas borrowed from ECMAScript 6. In many ways they are basically compiling ECMAScript 6 to ECMAScript 3 (the version of Javascript that works on all reasonably modern browsers.)

I put TypeScript in the same family as Dart. CoffeeScript is a relatively simple Javascript alternative while TypeScript and Dart are full OO languages designed for programming in the large. In addition to types they give you better modularity and classic OO constructs such as classes and interfaces.

I'm curious why Microsoft didn't just write a C# -> Javascript compiler similar to what Google did with GWT (Java -> Javascript). I suppose it was important for the language to be a superset of Javascript so programmers could always fall back to something familiar.

Sponsors

web design, web development, localization

© 2024   Created by Daniel Leuck.   Powered by

Badges  |  Report an Issue  |  Terms of Service