JavaScript is the most accessible cross-platform language nowadays. It’s used both on front-end and back-end website development. Using it Altabel developers create web-apps which includes offline mode, desktop apps, apps for smartphones and tablets, add-ins for Microsoft Office, SharePoint and Dynamics. And if you don’t get acquainted with JavaScript yet we strongly believe that you should do it immediately!
I reckon many of us know there are plenty of different languages compiled in JavaScript. It’s CoffeeScript, Dart, GorillaScript and others. To be fair some of these languages are fly-by-night creations that have never really taken off in the wild. But many of these languages are major engineering efforts with large ecosystems and large corporate backers. With so many frameworks and languages out there it can be difficult to figure out which one is the best.
In 2012 Microsoft analyzed the situation and created a new language with a possibility of dealing with problems and using existing JavaScript insights. Thus, a free open source programming language TypeScript was developed and maintained by Anders Hejlsberg (co-creator of Turbo Pascal, Delphi and C#). From the very beginning the new language started expanding rather quickly due to its flexibility and productivity. Considerable amount of projects written in JavaScript began to transfer to TypeScript. Popularity and relevancy of the new language leaded to the fact that lots of TypeScript ideas became the part of new JavaScripts standard afterwards. And moving forward the AngularJS 2.0 version (today one of the most popular web frameworks) was completely written on TypeScript with the help of Microsoft and Google.
But why TypeScript?
Let’s review main reasons of its popularity:
- TypeScript is a typed superset of JavaScript. In other words any valid JavaScript code is also valid for TypeScript.
- TypeScript may be used to develop JavaScript applications for client-side or server-side execution.
Microsoft’s TypeScript seems to generate the most attractive code and is considered to be one of the best JavaScript front-ends. TypeScript adds sweetness, but at a price.
- TypeScript can also be used with existing JavaScript frameworks/libraries such as Angular, jQuery, and others and can even catch type issues and provide enhanced code help as you build your apps.
- TypeScript can be just the right fit for projects in which developers try to remain relevant without the need to learn a whole new syntax.
The ubiquity of JavaScript as a runtime has inspired people from a variety of programming backgrounds to recreate JavaScript as they see fit. And yes, TypeScript lets you write JavaScript the way you really want to.
- TypeScript differs from JavaScript with possibility of evident static objectives, with usage maintenance of full-blown classes (just as in traditional object-oriented languages), and also with maintenance of logging on modules. It’s aimed at development speed raising, simplifying of legibility, refactoring and reusability of your code.
- TypeScript has many additional language features but defining types and creating classes, modules, and interfaces are some of the key features it offers.
- In TypeScript the same types are supported as well you would expect it in JavaScript. Types enable TypeScript developers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion and code refactoring.
- TypeScript implements many conceptions that are appropriate to object-oriented languages such as extending, polymorphism, encapsulation, accessibility modifiers and so on.
- Lots of TypeScript features have strict rules, so various code formatting errors are excluded. Which means that the possibility of incorrect implementation or inaccurate method invocations is eliminated.
- TypeScript potentially allows writing large complex programs more quickly. Thereafter it’s easier to maintain, develop, adjust to scale and test them in comparison with standard JavaScript.
Drawbacks
TypeScript has a number of other positive features that are out of the scope of this article. On the other hand, there are two significant minuses exist.
- Probably, the biggest minus is entry threshold and number of specialists on the market. Nowadays there are not so many specialists with solid experience in this language.
- In comparison with JavaScript, it’s needed more time for the development. It stems from the fact that apart from class implementation one should describe all enabled interfaces and method signatures.
TypeScript 2.0
There are some significant changes coming in TypeScript 2.0 that continue to deliver on the promise of making JavaScript scale. This includes a whole rewrite of the way types are analysed in the flow of the code and an opt-in feature that starts to deal with logic errors around the flexibility of things being undefined or null in JavaScript. Other features planned for TypeScript 2.0 include read-only properties and async/await downlevel support.
TypeScript creator Anders Hejlsberg already has plans for TypeScript 2.1 and beyond. Features envisioned for these releases include a new JavaScript language service in Microsoft’s Visual Studio software development platform and more refactoring support.
The most recent version, TypeScript 1.8, rolled out in February, includes several more features like F-Bounded polymorphism, string literal types, etc.
Conclusion
So, if you haven’t taken a look at TypeScript, I have hopefully convinced you that it is something to at least worth a bit of your time. It has some of the best minds focused on making JavaScript scale and the team is going about it in a way that is open and transparent. By embracing the reality of JavaScript and building on top of it, in my opinion TypeScript is transforming the common language of the web, for the better.
We will be happy to hear how you use TypeScript in your current projects, if you like it, if you are planning to switch to this language, what are the pros and cons in your opinion, etc. Feel free to share with your thoughts in comments below!