.NET Zone is brought to you in partnership with:

I'm software developer and microISV, with a lot of passion to technologies.. having a fun writing code, writing blog posts and giving public speeches. For about 10 years of total experince I've been working in many branches of software development, including management and QA. I try to follow and adopt agile practices and signed up for software craftsmenship manifesto. Alexander is a DZone MVB and is not an employee of DZone and has posted 35 posts at DZone. You can read more from them at their website. View Full User Profile

Looking At TypeScript

10.07.2012
| 543 views |
  • submit to reddit
The .NET Zone is supported by Altova, makers of the best-selling XML, UML, and Database tools with code generation in Java, C#, and C++, plus Visual Studio and Eclipse integration.
Four days ago my twitter has been nuked. The bomb has exploded after TypeScript site link has reach to top of Hacker News and people watched the video of Anders Hejlsberg who generally described the language features and showed some example. Everybody were talking about 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.

Published at DZone with permission of Alexander Beletsky, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

This content was brought to you by Altova, creators of the industry's best-selling XML, UML, and Database tools.  If you'd like to simplify your Data Management, XBRL Compliance, UML Modelling, Web Service Creation, or and sort of work with XML, Altova are the people you need to talk to.

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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.