3 Reasons to use TypeScript rather than Javascript

March 27, 2018
3 minutes read

3 Reasons to use TypeScript rather than Javascript

TypeScript and JavaScript are both web development languages, and we use both at Rubico. The TypeScript advantage makes it much easier to use across multiple browsers, in building large apps and using typings. Read on to learn more about this easy-to-use programming language.

What is Typescript?

Microsoft created Typescript (TS) as a superset of JavaScript (JS). As a superset, TypeScript envelopes normal JavaScript but has additional functions to it. Comparing TypeScript and JavaScript to each other is like comparing a simple screwdriver to a power tool. Both accomplish the same job, but the power tool does much of the work for you, just like TypeScript.

Why Typescript?

JavaScript is the language that shaped the modern web. It is fast, simple, and most importantly, easy to learn. It is also a dynamically-typed language. You can draw up a variable by just writing var a = “something”. But with JavaScript’s dynamic abilities you lose structure and discipline when creating an enterprise or product.

Now consider the TypeScript advantage. Since it is a superset of JS, it allows for both a dynamic approach, and also provides structure through the use of type checking. Where the language needs to be dynamic, TypeScript converts to JS. But when a dynamic language needs more order, TypeScript corrects the JS and provides structure.

1. Targets Multiple Browsers

Multiple Browsers
When targeting multiple browsers and attempting to use all the latest features of JavaScript, there is no need to use various building tools like Gulp or Webpack. With TypeScript, you can write the code once and specify which browser to target and TypeScript does the rest for you behind the scenes.

2. Creates Big Applications

Multiple Browsers
When creating a big application, or a product in which you want structure to the system, use the TypeScript advantage. This makes the project easy to maintain and creates it with as few bugs as possible. On the other hand, JavaScript would have the following immediate problems:

  • No inherent type casting/type hinting
  • Lack of OOPs (Object Oriented Programming)
  • No availability of new Javascript API’s in cross browsers and platforms
  • Lack of abstraction to provide base structure to a project
3. Type hinting and Typecasting

Multiple Browsers
TypeScript uses type hinting and typecasting so that a variable is given a certain number. Then the language will show the error while developing and resolve it even before it’s deployed. Without typings, it is not clear where a variable property is placed. When problems arise, resolving the issue takes much longer.

TypeScript provides a similar approach to OOPs in other languages than JavaScript’s prototype-based inheritance. This makes a developer, who’s working on both the front-end and back-end of the aspects, feel right at home. The developer will not need to learn new concepts of OOPs for JavaScript. Because of the similar approach to OOPs, you have the ability to create abstract classes and interfaces that can define a base structure for your application.

Giants using Typescript

Google’s Angular, the famous framework that changed the modern front-end framework with two-way binding, now uses TypeScript as its primary building block. Ionic, the mobile hybrid development ecosystem, also uses TypeScript over JavaScript to provide better tools and weapons to tackle mobile development.

Typescript for Frameworks

Many other frameworks out there, other than Angular, provide TypeScript as their second option. To name a few, Vuejs and React also have TypeScript typings available to build an application in a more robust way.

At Rubico we are using TypeScript on some of our projects. Get in touch with any questions you may have about JavaScript and the advantages of TypeScript. You can reach our team at solutions@RubicoTech.com.

Max Gaurav Software Engineer