Monthly Archives: October 2012

Have you heard about TypeScript?

JavaScript as a language does not have object-oriented patterns in mind. With this I don’t mean that you can’t write object oriented code, but you have to do it by your own. OO is not part of the language itself. Well, there are many frameworks which jump into this area by bringing some helper functions to get inheritance and all the workarounds needed for OO and modularization stuff. But as a result it blows up the JavaScript code and it gets even harder to read and maintain it.

Is TypeScript a bad idea? I think not, because it adds the syntactic sugar needed to concentrate on the app-logic and takes away the clutter needed for OO/modularization . Take a look to other languages: the language Objective-C extends the C programming language to object-oriented programming language, but it is C-code. Or take a look to C++. It adds object oriented features to the C programming language, so it can include C-code.

So take a step back and think about JavaScript as a language not as a runtime. Then I see TypeScript as the abstraction I’m waiting for a long time. Have a look at the TypeScript code below. On the left side all the OO-stuff and modularization is well abstracted and I can concentrate on the app-logic. On the right side is the code needed for app-logic and OO/ modularization stuff produced from TypeScript compiler. Of course after working for years with JavaScript you might be familiar with the right side also, but maintaining code like this is even hard.




And then there are other features such a type-checking, refactoring, etc. which TypeScript enables since the code contains type information.