javascript, typescript

Javascript and ES6 vs Typescript – Why should you learn TypeScript in 2019?

Presence of Javascript is everywhere, enhanced by superset languages such as ES6, and Typescript in various form and shape, either from frontend...

Written by admin · 3 min read >
Javascript vs Typescript - Should I learn Typescript in 2019

Presence of Javascript is everywhere, enhanced by superset languages such as ES6, and Typescript in various form and shape, either from frontend to middleware to backend or from web app to mobile app to desktop app. It is now used by an incredible number of high-profile applications, from enterprise to personal projects.

Let’s discuss Javascript and ES6 vs Typescript detailed comparison and find out the answer for common questions like Why should you learn TypeScript in 2019? What is better for your application Javascript or Typescript?

In this article, I’ll cover common concerns like Javascript vs Typescript, ES5, ES6, the learning curve for TS [Typescript], performance and popularity in 2019.

Javascript Overview

JavaScript is the most popular web scripting programming language in the world and almost every website uses JavaScript in some form.

It is not only used for the front-end but also is used for server-side and middle layer components developed. However, JavaScript is not designed for large complex applications. It was developed for applications.

Javascript in today world

Javascript is changing frequently due to the change in the user experience of the Web and App. Every year there are new updates, new libraries, new frameworks, and new languages. In 2019 not only Javascript use in client-side frameworks like Angular and React but it is present as a backend language like Nodejs and Machine learning domains.

Typescript Overview

Typescript is a statically typed superset of JavaScript that compiles to plain JavaScript. In other words, it’s JavaScript that scales.

Typescript Official Site

Typescript background

It first released for public use in October 2012. It was developed by Microsoft, with Anders Hejlsberg, the lead architect of c#, as well as the creator of Delphi and Turbo Pascal, and team. TypeScript is completely open sourced on GitHub, anyone can read the source code and contribute.

ES5, ES6 and Typescript

At this point in time, it is very important to understand these terminologies.

ES5 – Vanilla JavaScript which we have been writing all these years, Functional programming, All modern browsers support, also known as ES2014.

ES6[ ECMAScript 6 ] also known as ECMAScript 2015 is JavaScript with ‘types’. Bring it closer to strongly typed languages such as C# and Java. Legacy browsers still not supporting and It must be converted to ES5 to be executed in browsers. so a transpiler transpile the code from ES6 code to ES5 code.

If we compare both the Typescript vs ES6 we will not find the many differences. Everything we write in Typescript is supported by ES6 or vice versa. In simple words, Typescript is the extension of ES6 with some added features.

Developers always prefer Typescript because of its features like classes and modules but now the same features are also available in JavaScript (After ES6 introduced) and you can use Babel to transpile down to ES5 for greater browser compatibility. but here Typescript provides some additional features over ES6. So Typescript is Future ES2016+ features (such as Annotations/Decorators and async/await).

ES5, ES6 and Typescript

Difference between Javascript and Typescript

We can compare Javascript and Typescript based on some parameters:

Static vs Dynamic typings

Static typing allows developers to detect the bugs as writing the scripts. Typescript developed with the Static Typing feature whereas JavaScript was introduced as a weakly typed scripting language to make HTML dynamic. It supports Dynamic Typing.

Object-Oriented Concepts

Developers from C#, Java background face difficulty in write code in javascript as it is not an object-oriented programming language. Typescript is an Object-oriented programming language and supports most of OOP concepts while JavaScript is a scripting language.

Interface, Modules, Generics, Classes are few of the feature which makes Typescript more popular than Javascript. Typescript aims to produce more secure Javascript code using these concepts.

Are Javascript and Typescript the same?

Typescript to Javascript : Transpiler

Browsers do not understand the TypeScript and legacy browsers do not support the most of Typescript. That’s why TypeScript code, which is written in .ts file and compiled to Javascript and creates a .js file using the Typescript transpiler. So Typescript Transpiled into Javascript and with the help of JavaScript code, browsers are able to understand the code and display.

Javascript to Typescript

We can also convert typescript to javascript by changing the .ts extension to the .js file. There is a possibility that your .js code will not work up to some instance.

Typescript popularity graph in 2019

According to 2018 survey of stateofjs, Typescript has gained a lot of popularity in 2018. TypeScript gets more and more popular in the Front-end environment. Nowadays we have

Learning curve for Typescript

  • Typescript requires prior scripting knowledge whereas Javascript flexible and easy to learn, scripting language.
  • Knowledge of Object-oriented concepts will help you to learn easily.
  • You must be aware of terminology like Classes, Interface, generics, inheritance, ES6 features will give you extra confidence to learn Typescript

Why should you learn TypeScript?

 Better performance for Large Coding Projects

  • For Large codebase, the overall performance of Typescript is far better than Javascript and ES6.
  • It offers better productivity and Maintainability for developers.
  • Integration with IDE VS Code provides better code navigation and catching bugs before compilation.
  • Static Typing , object-oriented concepts and additional Features over ES6 help the developer to understand the problems in real time.
  • Code easier to understand, Increase the performance

Better for Productivity and Collaboration

  • Tools like TSLint is standard linter for Typescript to catch the bugs at the time of writing the code, before compiling.
  • Rich IDE available with autocomplete and code navigation features.
  • Code easier to merge
  • Support from the big community like Angular, Microsoft.

Conclusion

What is better for your application?

  • For small size projects, I would recommend Javascript is an ideal option, but for large size projects and codebase, you can use Typescript.
  • In very simple words, Typescripts = ES5 + ES6 + additional features .
  • So if you have the prior javascript knowledge and expertise development team, then Typescript is the most preferred option.

So we had a detailed discussion over this topic. If you like the article please appreciate and share your feedback with me. Happy Learning…

Leave a Reply

Your email address will not be published. Required fields are marked *