Looking At TypeScript
For ones who missed the video (I can't believe you did) I shortly describe - TypeScript in new open source project, by Microsoft. It's leader Anders Hejlsberg is very famous developer (my bad, I always forget his name), creator of C# and one of the persons who most influenced .NET platform. TypeScript compiled down to JavaScript, but it introduce the types checking during compilation, so it could be called 'static typed language'.
First of all, TypeScript is definitely not the first language, that complies to JavaScript. It's not the first one that augments JavaScript with new statements like class, interface or module. So, what's so interesting on it?
I've been using static type languages for about 10 years. I've very much got used to compiler error messages and truly believed that it helps to build applications. Meaning, the complier is first guard towards the 'good' code. To the code that could be called reliable, error free.
But situation much changed after I start programming JavaScript.
I feel myself quite productive with using of using JavaScript. Of cause, there are some best practice & patters are collected nowadays, we have better tools, faster engines and JavaScript has been so much adopted by community. But JavaScript is indeed, so powerful language. I really like the dynamic typing, that bit more forces to unit testing, making code changes more easy in the same time creating some very beautiful code structures.
I know that some people are saying, "we don't need any static typing for JavaScript; please don't change the language". Such developers could be called "purists". And they are absolutely right - if you feel confidence in something you do, you should not change the way you do it.
In another hand, I came to conclusion that it's not dynamic types that makes me productive with JavaScript, but rather the experience I gathered with programming lately. It's always only experience, that allows you to work faster, better quality and had fun of your job.
And it's absolutely not about Static vs. Dynamic languages.
Static types are not useless, though. I think, in average it reduces the chances of bug introduction into the code. That's at least what I've seen so far. And that's why "purists" are running JSLint. Basically, Static Types should provide better application quality. This is of cause not completely true, since we know great software written in Python and poor systems written in C++.
It' about the engineers who build that software.
In my opinion the TypeScript will grow. It would have it's own army of fans, like CoffeeScript have or Ruby have. The code that TypeScript outputs is nice and clean, that make easy of debugging it. TypeScript is designed to be closer to ECMAScript6 (Harmony), so in near future the pure JavaScript would start to look like TypeScript.
TypeScript is interesting project and open minded guys will like one.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)
Comments
Paul Topping replied on Mon, 2012/10/08 - 11:17am
There is another advantage of static typing that should not be overlooked. It should be possible to get fairly huge gains in performance in future implementation of JavaScript. When a compiler "knows" that a variable can only contain values of a single type, it can optimize it by an order of magnitude over the general case.
Since TypeScript compiles to JavaScript right now, this optimization is not probably not going to happen right away. However, when static typing becomes part of some future version of JavaScript, all JavaScript interpreters should be able to optimize.
It might even be possible to do today if TypeScript embedded its type information in the generated JavaScript code, probably as some kind of comment. However, this might cause problems for programs that mix TypeScript-generated JS with hand-coded JS. While TS-JS can guarantee a given variable is used to hold a single type of data, it can't be certain that the hand-JS doesn't try to stick some different type value in that same variable. Of course, there are a million ways a programmer can write bad code so perhaps this would be considered a non-problem.