Developers
October 9, 2020

Why Has TypeScript Become So Popular?

TypeScript has been gaining in popularity, surprising many programmers.

One of the more surprising trends of the past couple of years is the growing popularity of TypeScript. In fact, according to Stack Overflow’s 2020 Developer Survey, TypeScript is second on the list of most-loved languages, coming it at 67.1%, just behind Rust.

What is TypeScript? What features set it apart? What accounts for its rise in popularity?

What Is TypeScript?

TypeScript is a language that Microsoft released in 2012, following a couple of years of internal development. The language was designed to be a superset of JavaScript. As a result, it offers full JavaScript compatibility but builds on the older language with new capabilities. This means that existing JavaScript applications are automatically valid TypeScript apps.

Microsoft has demonstrated its faith in the language by placing it on the same level as C#, as one of its premier languages. As an added benefit, TypeScript is an open-source project, ensuring wide developer support.

What Features Set TypeScript Apart?

Despite its compatibility with JavaScript, TypeScript does provide a number of advantages.

One difference between JavaScript and TypeScript is that TypeScript is a compiled language. TypeScript compiles directly to JavaScript.

One of the biggest things that set TypeScript apart from JavaScript is optional static typing. JavaScript uses dynamic typing, meaning that value types are not assigned. While this can make it faster and easier to write code, it also makes it easier for errors to creep in, since checking only occurs at runtime. As a result, JavaScript can be prone to errors that only show up once the application is running.

In contrast, TypeScript allows static typing or defining value types. These are checked at compile-time, helping catch errors before the program is run. This makes TypeScript an excellent choice for larger applications, as it is easier to catch errors before they become a problem in a production environment. This is one of the biggest factors that has led companies to adopt TypeScript over JavaScript.

Why TypeScript Has Become So Popular

Felix Rieseberg, Slack’s Senior Staff Engineer, described the benefits of switching from JavaScript to TypeScript for the desktop version of Slack, highlighting a big reason for its popularity:

First, we were surprised by the number of small bugs we found when converting our code. Talking to other developers who began using a type checker, we were delighted to hear that this was a common experience: the more lines of code a human writes, the more inevitable it becomes to misspell a property, assume the parent of a nested object to always exist, or to use a non-standard error object.

Second, we underestimated how powerful the editor integration is. Thanks to TypeScript’s language service, editors with an autocomplete function can support the development with context-aware suggestions. TypeScript understands which properties and methods are available on certain objects, enabling your editor to do the same. An autocomplete system that only uses words in the current document feels barbaric afterward. Gone are the days we find ourselves on Google, checking yet again which events are available on Electron’s BrowserWindow. Plugins are available for Atom, Visual Studio Code, Sublime, and nearly every other editor out there. Being able to validate our code without leaving the editor boosted our productivity immediately.

Rieseberg went on to highlight how committed Slack is to the continued use of TypeScript:

The typeScript was such a boon to our stability and sanity that we started using it for all new code within days of starting the conversion. It’s taken about six months to annotate most of the JavaScript in the desktop app codebase.

Another boon to TypeScript’s popularity has been its adoption by other frameworks, most notably Angular. In addition to Angular, however, the Aurelia, Ember, Glimmer, Ionic, and NativeScript frameworks all support TypeScript to some degree or another. This results in tremendous confidence in the language and its future.

Another factor helping its popularity is the fact that using it is not an either-or choice. Because of its deep compatibility with JavaScript, TypeScript allows developers to ease in, rolling it out as they become comfortable. As the TypeScript website highlights:

Adopting TypeScript is not a binary choice, you can start by annotating existing JavaScript with JSDoc, then switch a few files to be checked by TypeScript and over time prepare your codebase to convert completely.

TypeScript’s type inference means that you don’t have to annotate your code until you want more safety.

Conclusion

TypeScript builds on what makes JavaScript great, adding important features and abilities that make it even better. It’s ideally suited for large applications and provides better error checking than JavaScript.

What’s more, TypeScript is widely supported by some of the most popular frameworks in the industry, ensuring its long-term survival.

TagsTypeScriptJavaScriptProgramming Languages
Matt Milano
Technical Writer
Matt is a tech journalist and writer with a background in web and software development.

Related Articles

Back
DevelopersOctober 9, 2020
Why Has TypeScript Become So Popular?
TypeScript has been gaining in popularity, surprising many programmers.

One of the more surprising trends of the past couple of years is the growing popularity of TypeScript. In fact, according to Stack Overflow’s 2020 Developer Survey, TypeScript is second on the list of most-loved languages, coming it at 67.1%, just behind Rust.

What is TypeScript? What features set it apart? What accounts for its rise in popularity?

What Is TypeScript?

TypeScript is a language that Microsoft released in 2012, following a couple of years of internal development. The language was designed to be a superset of JavaScript. As a result, it offers full JavaScript compatibility but builds on the older language with new capabilities. This means that existing JavaScript applications are automatically valid TypeScript apps.

Microsoft has demonstrated its faith in the language by placing it on the same level as C#, as one of its premier languages. As an added benefit, TypeScript is an open-source project, ensuring wide developer support.

What Features Set TypeScript Apart?

Despite its compatibility with JavaScript, TypeScript does provide a number of advantages.

One difference between JavaScript and TypeScript is that TypeScript is a compiled language. TypeScript compiles directly to JavaScript.

One of the biggest things that set TypeScript apart from JavaScript is optional static typing. JavaScript uses dynamic typing, meaning that value types are not assigned. While this can make it faster and easier to write code, it also makes it easier for errors to creep in, since checking only occurs at runtime. As a result, JavaScript can be prone to errors that only show up once the application is running.

In contrast, TypeScript allows static typing or defining value types. These are checked at compile-time, helping catch errors before the program is run. This makes TypeScript an excellent choice for larger applications, as it is easier to catch errors before they become a problem in a production environment. This is one of the biggest factors that has led companies to adopt TypeScript over JavaScript.

Why TypeScript Has Become So Popular

Felix Rieseberg, Slack’s Senior Staff Engineer, described the benefits of switching from JavaScript to TypeScript for the desktop version of Slack, highlighting a big reason for its popularity:

First, we were surprised by the number of small bugs we found when converting our code. Talking to other developers who began using a type checker, we were delighted to hear that this was a common experience: the more lines of code a human writes, the more inevitable it becomes to misspell a property, assume the parent of a nested object to always exist, or to use a non-standard error object.

Second, we underestimated how powerful the editor integration is. Thanks to TypeScript’s language service, editors with an autocomplete function can support the development with context-aware suggestions. TypeScript understands which properties and methods are available on certain objects, enabling your editor to do the same. An autocomplete system that only uses words in the current document feels barbaric afterward. Gone are the days we find ourselves on Google, checking yet again which events are available on Electron’s BrowserWindow. Plugins are available for Atom, Visual Studio Code, Sublime, and nearly every other editor out there. Being able to validate our code without leaving the editor boosted our productivity immediately.

Rieseberg went on to highlight how committed Slack is to the continued use of TypeScript:

The typeScript was such a boon to our stability and sanity that we started using it for all new code within days of starting the conversion. It’s taken about six months to annotate most of the JavaScript in the desktop app codebase.

Another boon to TypeScript’s popularity has been its adoption by other frameworks, most notably Angular. In addition to Angular, however, the Aurelia, Ember, Glimmer, Ionic, and NativeScript frameworks all support TypeScript to some degree or another. This results in tremendous confidence in the language and its future.

Another factor helping its popularity is the fact that using it is not an either-or choice. Because of its deep compatibility with JavaScript, TypeScript allows developers to ease in, rolling it out as they become comfortable. As the TypeScript website highlights:

Adopting TypeScript is not a binary choice, you can start by annotating existing JavaScript with JSDoc, then switch a few files to be checked by TypeScript and over time prepare your codebase to convert completely.

TypeScript’s type inference means that you don’t have to annotate your code until you want more safety.

Conclusion

TypeScript builds on what makes JavaScript great, adding important features and abilities that make it even better. It’s ideally suited for large applications and provides better error checking than JavaScript.

What’s more, TypeScript is widely supported by some of the most popular frameworks in the industry, ensuring its long-term survival.

TypeScript
JavaScript
Programming Languages
About the author
Matt Milano -Technical Writer
Matt is a tech journalist and writer with a background in web and software development.

Related Articles