Historically, JavaScript has become the main language for scripting web pages and apps on the Internet, but recently there's a new language that's gaining popularity and it's increasing so fast that people are starting to prefer it over JavaScript.

If you haven't figured it out yet we're talking about TypeScript! For the last couple of years, it has been increasing in popularity as one of the largest fronted frameworks and superset of javascript. And on this blog we're gonna talk about why you should use it!

Now for starters TypeScript is a superset of JavaScript that has optional typing and compiles to plain JavaScript. In other words, TypeScript technically is JavaScript with static typing, whenever you want to have it.

Now let's clarify something before going further into detail, we're not saying one is better than the other, we're just simply explaining why some people prefer one over the other so that you can make your own opinion and act based on it!

Let's start with the good part, we can mention a few reasons why TypeScript is prefered and might be better to use:

  • TypeScript simplifies JavaScript code, making it easier to read and debug.
  • With TypeScript, we can make a huge improvement over plain JavaScript.
  • TypeScript can help us to avoid painful bugs that developers commonly run into when writing JavaScript by type checking the code.
  • TypeScript will save developers time.

Basically TypeScript is nothing but JavaScript with some additional features that make it for you a little easier to code, those cool features are:

  • Generics support.
  • Modules support.

We have to be realistic and we know that bugs in programming are inevitable! There are cases of cases, it may be a typographical error or it may have been a rushed job without the necessary time to do error tests. And the advantage of TypeScript over JS is that it makes a developer's job easier by helping them identify by type checking the code.

One of the dangers of freedom in dynamic typing is that it can decrease the efficiency of the programmer and his work and it can stop the development of the project because it increases the cost of adding new lines of code.

Therefore, the fact that JavaScript does not incorporate things like typing and compile-time error checking makes it a poor choice for server-side code in enterprises and large code bases. As its motto says, TypeScript is JavaScript that scales.

Now talking about Back and Front end (remember we also have a blog talking about this topic click here if you wanna refresh your mind)... Is TypeScript even used on the frontend and backend?

Actually, TypeScript is compiled to JavaScript, like we said before they're technically the same. Therefore, TypeScript can be used anywhere JavaScript could be used which means it can be used on both the frontend and the backend. Of course JavaScript is the most popular scripting language for front-end applications and web pages BUT TypeScript shines not only for serving the same purposes as JS but also for complex server-side business projects.

This is what some people said about TypeScript (there is nothing better than seeing the experience of others about something that interests us):

  • “We love TypeScript for many things… With TypeScript, several of our team members have said things like ‘I now actually understand most of our own code!’ because they can easily traverse it and understand relationships much better. And we’ve found several bugs via TypeScript’s checks.— Brad Green, Engineering Director – Angular
  • “TypeScript is a smart choice when writing a modern web- or JavaScript-based application. TypeScript’s carefully considered language features and functionality, and its consistently improving tools result in a terrifically productive development experience.” — Aaron Cornelius, Research Fellow – Epic

If you've made your mind and you would like to learn more about TypeScript, here are a few other resources that you can check out:

  • TypeScript Documentation. The official documentation features great guides for beginner TypeScripters, including guides for those switching from other programming languages.
  • TypeScript Deep Dive. This free web resource has everything you need to start off with TypeScript, including more detailed explanations of the sections we’ve already covered here.
  • Programming TypeScript: Making Your JavaScript Applications Scale. This is a great book for those of you already fluent in JavaScript. It will help you get up and running with writing TypeScript in no time.
  • Learn TypeScript From Scratch! A practical 3-hour course that goes through all the basic functions of TypeScript, how to use it to interact with some JS frameworks, and how to use the power of TypeScript while writing JavaScript.
  • Exercism. This is the best resource to practice writing code in a new programming language. Mentors that will steer you towards idiomatic code, lots of fun practice tasks – there is nothing not to love about this website.

We think TypeScript is a tool worth exploring and having in your toolkit, even if you don't use it fully it will always come in handy!

Remember that nothing is learned overnight and you can grow and learn little by little, you can take your time to understand the tool 100% and thus also increase your level of experience. If you are a beginner, TypeScript is a pragmatic and quite intuitive tool, there is no reason to be afraid of it.

I hope this quick guide has been useful to you! For more content like this, remember to activate notifications on Elaniin's social networks and not miss any publication of our blog!