Is Javascript Dead? Typescript Won?

You might see Typescript in vacancies a lot nowadays and you might think "Is Javascript dead"? Do I need to learn it at all or I need to start directly with Typescript?

Actually last 5 years every time when I wrote an application for business or for myself I did it in Typescript. So I can say "I don't use plain Javascript for production anymore".

And it doesn't have anything to do with Typescript being a trend but that Typescript brings stability in our applications. For Javascript it's typical to debug in runtime. You just wrote a variable wrong and you spent half of an hour debugging your code cause the value somewhere is wrong. Or you get standard "Cannot read property of undefined".

Error

This all happens because Javascript is not safe.

You don't have a possibility to see errors and validation rules before they get to runtime where it is already too late.

Secondly we don't have custom data types in Javascript. Sure we have strings, arrays and objects but we can't define our own types for them. We implement the list of users and we just use the array of objects, we don't validate that every object inside is correct and has all properties that our user has.

const users = [
  {
    id: 1,
    name: 'foo'
  }
]

console.log(users[0].surname)

All this things and cons of Javascript which is why Typescript is getting more and more popular. It fills this gaps of static typing and entities organisation in your application this is why so many people say that "Javascript is dead".

Is Javascript dead?

But it's important to understand that Javascript is a most popular language in the world. And when people say that "Javascript is dead" they mean that plain Javascript without static typing is not that popular anymore. And you want for sure say now "But my company is using React just with plain Javascript and we are doing fine". Sure it is still possible and popular but trend is going in the direction of Typescript. Especially if you do big project for business people want additional safety which is not possible to get with React.

Should I learn Javascript or Typescript?

And my students are asking me often "Should I learn Typescript if I don't know Javascript? Should I bother with Javascript if Typescript is becoming more popular". And the correct answer is yes you must learn Javascript first. Typescript is not another language it's just typings around Javascript which allow to validate our code before it gets to runtime. So first you must learn Javascript it's data types, loops, conditions, classes, working with DOM and only then look in the Typescript direction.

Typescript doesn't cover basic Javascript knowledge and Typescript is not easy to master. It's not only to learn how to type your code but you need to understand how to organize your entities with Types and interfaces to make it scalable and supportable. Also it's not easy to debug Typescript errors with data types. Most beginners who don't understand the purpose of Typescript just disable Typescript rules in specific lines to finish project faster. It doesn't bring anything in a long run, your project will be simply not bulletproof.

Is developing faster?

One most thing that I hear often is "Developing with Typescript is slow. I need to write my code and additionally all my typings". And it is completely valid. You will spend more time writing Typescript code that Javascript code because you create typings and interfaces, sharable generics, organize all your entities to fit the application and it takes time. But for some reason people don't calculate time to find each variable that they wrote not correct or function that they called with incorrect arguments. Debugging and building scalable code is much easier to do with Typescript and in the long run you spend less time in total with all this safety than without it.

Also Typescript helps to write your code much stricter. It will scream on every not covered condition or variable that might be undefined. Your code will have more cases and error handling and it will be more safe and you will for sure cover not the happy path as in Javascript.

Do you need to learn Typescript?

Do we need to use Typescript for all projects? Of course not. If you write 100 lines of Javascript for your project you don't need Typescript but for medium and big applications I always recommend to use Typescript. Sure if you never used Typescript it will slow you down but it will make your application safer.

Do you need to learn Typescript? If you don't know Javascript on a good level then no. First focus on Javascript, use it confidently and only then start learning Typescript. If you already know Javascript and think if you need to bother with Typescript then yes for sure. It will improve your overall code, you can find jobs which use Typescript and are better paid and it won't disappear in the next year or two. It is already in thousands of applications and companies, we have lots of libraries build with Typescript and it's completely safe to invest your time in Typescript.

Want to conquer your next JavaScript interview? Download my FREE PDF - Pass Your JS Interview with Confidence and start preparing for success today!

Did you like my post? Share it with friends!
Don't miss a thing!
Follow me on Youtube, Twitter or Instagram.
Oleksandr Kocherhin
Oleksandr Kocherhin is a full-stack developer with a passion for learning and sharing knowledge on Monsterlessons Academy and on his YouTube channel. With around 15 years of programming experience and nearly 9 years of teaching, he has a deep understanding of both disciplines. He believes in learning by doing, a philosophy that is reflected in every course he teaches. He loves exploring new web and mobile technologies, and his courses are designed to give students an edge in the fast-moving tech industry.