Thursday, June 18, 2015

What is TypeScript? Why would i strongly recommend to use it in your next project

As all of us know, Building large applications in JavaScript is hard! It gets messy and hard to manage and test.

The Problem
Because of the nature of JavaScript, it is not "favorable & easy practice" for non JavaScript developers to write classes, modules, OOP code in an easy, clean and straight forward way.

This was the reason of the rising & popularity of JS libraries and frameworks such as: jQuery, Angular, Knockout and much more amazing js libraries.

Recently, I have been thinking to build a Hyprid mobile application using Cordova, and this open source platform helps developers to build cross platform native apps using standard web technologies in JS and HTML.

I was thinking what is the right and best approach to start structuring my project in an organized pattern such as MVC, so i have bunch of views and controllers and my code is clean to build robust solution!

The Solution
You have different ways to implement this, One is to use Angular JS library that helps you strcture your code in a MVC patterns and design your views that are linked to models and js files that have all your controllers implementations.

Another approach, is to use TypeScript which gives your the ability to write clean client scripting and it generates JS code for your and it works in all browsers!

If you are using any OOP programming language such as: C# or Java. It will so easy for you to add TypeScript (*.ts) file in your project and start writing classes, interfaces and all OOP code with IntelliSense and type casting capabilities within VS IDE.

So, you write C# Like code in TypeScript file, it generates JS code and it works in al browsers.

Here is a play ground site to test it some code and see generated code:

The same site has tons of materials to learn, samples and get started:

TypeScript is available and supported if you use VS 2013 (update 2) or VS 2015!

Hope this helps!

No comments: