TypeScript. It seems that nowadays everyone loves it! Its popularity is skyrocketing and by now, it’s one of the fastest trending languages in recent years. According to a Stack Overflow survey from 2019, it is the 3rd most loved and 4th . Why has it become so popular? Well, let’s find out why the buzz and how TypeScript looks compared to its older brother, good old JavaScript.
It all started in 1995 with JavaScript, which made websites interactive. Before that time, websites were just simple, static pages. As web applications became more and more popular, modern JavaScript frameworks appeared. Now JavaScript is everywhere, it is used in your browser, on the server side, even your desktop and mobile applications are using JavaScript. Mainly because it is very flexible, dynamically typed and allows the writing of code in many paradigms.
However with this popularity and freedom comes the price of increased complexity, which may be the reason for the many bugs. That’s why TypeScript was created. To help developers make better, scalable projects to the highest standards.
But is TypeScript always better than JavaScript, and what are the exact differences?
In this article, we will try to compare these two languages and find out whether you should use JavaScript or TypeScript in your project.
First things first. JavaScript is a subset of TypeScript. That means that every JavaScript code is a valid TypeScript code. If you know JavaScript already that means that you will have a relatively flat learning curve and you can easily refactor your project’s code from JavaScript to TypeScript to suit your learning pace.
One of the popular benefits of using TypeScript is that you can use some features which are still in proposal for the next version of JavaScript and which are not yet supported by all browsers. It is possible because TypeScript code is transpiled to the JavaScript version specified in compilerOptions in the configuration file tsconfig.json. JavaScript features from ES6 were available in TypeScript 3 years earlier so developers had an opportunity to get used to the new syntax. It is safe to say that the TypeScript community is speeding up the progress of JavaScript development.
Both JavaScript and TypeScript support object-oriented programming language features like classes and inheritance. Additionally, TypeScript supports abstract classes, interfaces, decorators and access modifiers.
Replies