Why You Should learn TypeScript Over JavaScript as a Beginner

How TypeScript can help you write error-free, structured and fast code as a beginner.

Max Manthey
arconsis
6 min readMar 29, 2023

--

Recently, our marketing team approached me and, asked if I’d be interested in streaming on the company’s Twitch channel. The idea of the channel is to share our knowledge in software engineering related topics with the audience. Even though I don’t usually use Twitch much, I was intrigued by the idea and started thinking what I could stream about.

Quickly, I came up with the idea that I could teach one of my colleagues from the marketing team how to code on stream. The reason I wanted to teach someone else directly in front of the camera rather than “the viewer” behind the screen is that I could answer any questions right away and could also be called out if I was going too fast or if something I said wasn’t clear.

As a web developer, my first instinct was of course to teach JavaScript. After all it is the language I was “raised” on myself and that I love but as you might’ve guessed from the headline I chose TypeScript instead. In case you don’t know, TypeScript is a superset (or flavor) of JavaScript. In this article, I want to explain my choice to you and why I think that you should learn and use TypeScript instead of JavaScript as well.

The State of JavaScript Survey

For those of you not in the know, “The State of JS” is an annual survey that had 39,472 people participating this year alone. No matter how deep into the JavaScript / TypeScript universe you are, the survey answers everything you’d ever want to know — from the popularity of frameworks to runtimes and tools.

Popularity of JS flavors by percent of question respondents. Source

One of the questions is about the JavaScript flavors being used by the participants. I was not very surprised to see TypeScript so far ahead of the competition (if you can call it a competition at this point). Since JavaScript is not mentioned in this statistic, you don’t get a clear picture of how many people are using TypeScript in comparison. This used to be the case for the past few years and just left people guessing.

This year, however, the team at The State of JS has added a new Usage section. Inside the section are some very interesting statistics, such as “What do you use JavaScript for?”.

But the one that stood out to me the most in this section (and maybe the entire survey) was this one:

Balance between JS and TS by percent of question respondents. Source

As most of the people who responded to the survey are professional developers, I was frankly shocked by the results of the JS/TS balance question. Although TypeScript has seen a meteoric rise in popularity, I expected that most developers were still using JavaScript in their day-to-day jobs and personal projects and that the switch to TypeScript would be a slow one, especially for larger projects.

Well, clearly — I was wrong.

The answer to that question speaks for itself. Seeing such a high number of developers using TypeScript over JavaScript just warms my heart. ❤️

But why do I, and (as you just saw) many other developers prefer TypeScript over JavaScript? And why do I think that people who are new to programming and want to learn JavaScript should choose TypeScript instead? The same goes for developers who already know other programming languages and are not sure if they should learn TypeScript or JavaScript.

Now, I know that so far I might’ve sounded a bit biased, and while that’s probably true, I’m going to try to convince you with some straight facts about the two languages. However, I do want to say that I’ve done a lot of work with JavaScript in the past and I immensely enjoy the language as well.

So, without further ado… Let’s jump right in!

Why TypeScript > JavaScript

The world of web development can seem quite overwhelming when you are a new developer (or even to an experienced developer from another field). With so many frameworks and tools to choose from, it can be difficult to know where to start. Personally, I believe that it is important to build a strong foundation. Really understanding the basics of HTML and CSS might seem mundane, but it can go a long way. The same goes for JavaScript/TypeScript.

To not overwhelm yourself in the beginning it would be wise to pick one of the two languages and then dive in deep.

There are a couple of good reasons to choose TypeScript over JavaScript.

Strong Typing

TypeScript is a statically typed language, which means that variables must be declared with a specific type (if you set the right linter rules). This may seem like a hassle at first, but it actually makes your code easier to read and reduces the chance of runtime errors.

Improved Tooling

TypeScript was developed by Microsoft and has been adopted by many of the largest companies in the tech industry. As a result, there is a wealth of tools and resources available to TypeScript developers. For example, most popular code editors and integrated development environments (IDEs) now have built-in support for TypeScript. This makes it easier to navigate your code and find errors before they cause problems.

Future-proofing

JavaScript is a language that has evolved over time and will continue to do so. However, TypeScript is based on JavaScript and will always be compatible with it. This means that as JavaScript evolves, TypeScript will evolve with it, making your code future-proof. In addition, TypeScript is already being used by many large companies, so it’s likely that the demand for TypeScript developers will continue to grow.

Better scalability

TypeScript is designed to be scalable, making it easier to build and maintain large projects. With TypeScript, you can use features such as interfaces and classes to structure your code in a logical and organized way. This makes it easier for you and other developers to understand the code and add new features as needed.

Switching to JS is easy

Let's face it. As Web Developers we have to manoeuvre through very different terrains. Even if you just know TypeScript, at some point in your career you'll have to write JavaScript and the other way around too.

If you already know TypeScript and need to work with JavaScript code, you’ll find it to be extremely easy. It’s going to feel just like TypeScript, minus well… the types. Switching from JavaScript to TypeScript on the other hand is a whole other story. As someone who’s been in that position before, I can tell you that using TS, when you’re used to JS can feel quite overwhelming.

Conclusion

I like to compare the difference between JavaScript and TypeScript to driving a car. When JavaScript is driving an automatic car, TypeScript is driving manual. If you know how to drive a stick shift, you know how to drive an automatic, but not the other way around.

If you’re just starting to develop, choosing to learn TypeScript over JavaScript is a smart move. With its strong typing, improved tooling, better scalability, and future-proof design, TypeScript provides a solid foundation for your future career in web development. So why not start learning TypeScript today and see for yourself the benefits it can bring to your development journey?

A great place to start your TypeScript journey is our aforementioned series, which you can also find on YouTube.

However if you’re more interested in backend development, I can recommend Quarkus and Kotlin to you. Learn how to set up your first project here.

--

--

Max Manthey
arconsis
Writer for

Full Stack Software Engineer @arconsis. Coding enthusiast and lifelong learner.