Geek Culture
Published in

Geek Culture

Is TypeScript the future of JavaScript?

Exploring TypeScript and why it’s popular.

Photo by Fotis Fotopoulos on Unsplash

As a recent Software Engineering graduate. I see more and more companies are seeking TypeScript experience on their job listing and today I will get into a brief explanation of what TypeScript is and why employees are seeking for TypeScript developers.

What is TypeScript?

TypeScript is a programming language designed by Microsoft in 2012, it originated from the shortcomings of JavaScript development for large scale applications. TS(TypeScript) is basically a superset of Javascript that adds optional static typing to specify objects in programming. TS uses a compiler to compile TS code into JS(JavaScript). Due to the added features and efficiency, TypeScript has exploded in the programming community since their debut in 2012. According to Github language Data in 2020, TypeScript’s popularity has overtaken languages such as C++/C# and Ruby and the demand is still increasing by the day.

Why use TypeScript?

There are many reasons to use TypeScript but here is a list of my Pros and Cons for using TypeScript

Pros

  • TypeScript Compiler-This is probably my favorite reason to use TS. With TypeScript, you can use the TSC(TypeScript Compiler) to choose a target version of ECMAScript to translate your TS code into. This is super helpful in the case if you know your target customer base won’t have a modern browser, you can simply set your TSC to compile your code into older versions of JS that can be run on older browsers.
  • Static Typing-Javascript is dynamically typed and won’t know what type a variable is until the code is ran at run-time. TypeScript adds the option to specify types to variables which will help catch a lot of type based errors at the IDE level instead of a run-time error for cases such as adding a string of “1” to a variable instead of the number 1.
  • IDE Support-It offers a lot of built-in info related to your code since TypeScript is developed by Microsoft, it is widely supported by Visual Studio & VS code and various IDEs such as Atom and Sublime editor.
  • Super Set of JavaScript-TypeScript is a super set of JavaScript, making it super easy for JS developers to adapt to TS syntaxes since you are just writing JS code with added functions and features
  • Cross Platform-The TypeScript compiler can be installed on popular operating systems such as Windows, MacOS and Linux.

Cons

  • Extra code-You will have to spend more time writing code, if you have to specify the Typing of a bunch of variables in a big project. This Con is also kind of a Pro in my opinion, you might have to spending a little extra time writing code today but the value of preventing small future errors is a pretty good trade off.
  • Learning Curve-Since TypeScript is a super set of JavaScript, there can be quite a bit of a learning curve since you ultimately HAVE to learn JS in order to use TS.
  • Compiling Time-Since TypeScript needs to compile the code into JS, that can take time depending on the size of the project and the strength of your CPU which can cause a bit of lag while live coding.
  • Project Conversion-Due to its complexity of strict typings, it can be troublesome and time consuming to convert larger older JavaScript applications into modern TypeScript applications.

How to install TypeScript

You can simply install TypeScript with your package manager such as yarn or npm

npm install -g typescript

What this command does is install the TypeScript Compiler to your local environment. After the installation is complete, you can create .ts files and compile them with the tsc command.

//Exampletsc app.ts

Once the compiler is complete, you will see a .js file along with your .ts file that was just compiled.

Resources to learn basic TypeScript

Conclusion

The official slogan for TypeScript is “JavaScript that scales” and I find this to be really appropriate for this programming language. Since I am a JavaScript developer myself, I personally love switching over to TypeScript and it’s new features and functions that it brings to traditional JavaScript.

I am currently working on a personal big scale project with TypeScript and I will be providing future blogs on how to use TypeScript, so stay tuned!

Thank you for reading and please leave a comment if you‘ve enjoyed and follow for more coding content.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steven Wu

Steven Wu

I’m a NYC based full stack developer and a part-time gaming nerd https://www.linkedin.com/in/stevenwubc/