DEV Community

Cover image for Why learn Typescript as a Beginner?
prodbyola
prodbyola

Posted on • Updated on

Why learn Typescript as a Beginner?

Learn to write less buggy code!

In the world of frontend development for web, three tech in a stack play major roles – HTML, CSS and Javascript. Beginners usually find Javascript to be the most dreaded of them. With HTML and CSS, you simply learn how to lay out and design web pages, but Javascript introduces beginners to the core concepts of programming. You begin to write sequence of codes that tells the computer (Browser) what to do at certain point and time.

We could say Javascript is king of the web. But like every other programming language, it’s a king with its own flaws. Since this post is aimed at beginners, the goal is not to discuss the technical down sides of using Javascript. However, we’ll mention one particular flaw that is important for beginners to be aware of – which is the fact that Javascript is a dynamically typed language, which means it applies weak rules on programmers, which means you can write a terrible line of code and no compiler will complain, which means as a beginner it allows you to easily shoot yourself in the leg, which means you begin your programming journey by learning only to write mostly buggy codes.

For example, take a look at this Javascript code:

let number = 10;
let string = "5";

let result = number + string;

console.log(result); // Output: "105" instead of 15
Enter fullscreen mode Exit fullscreen mode

Does that mean you cannot shoot yourself in the leg when writing in statically typed languages? Does that mean you cannot write buggy programs in other languages? No! The chances are just slimmer even if the learning curve is higher. An advanced Javascript programmer might have learnt the rope and know how to avoid certain runtime bugs but the concepts that make this journey less difficult for beginners are often avoided in Javascript. Typescript being a superset of Javascript (i.e built on top of Javascript) is desgined to address some of these issues... as we’ll see in upcoming Part Two of this post.

Thanks for reading. I’d like to know what you think or if you have any question.

We have an 8-week online practical Frontend Development training coming starting on Feb 5, 2024. Click here to get started https://wa.link/bmondb

Top comments (0)