Header Ads Widget

Responsive Advertisement

What is TypeScript and Should you Learn it?

What is TypeScript and Should you Learn it?

I want to give you a very quick introduction to an awesome programming language called TypeScript. Typescript is a fairly new programming language. It was released in 2012 by Microsoft and since then it's become massively popular. It's taken over a ton of front-end work for large applications. It's really popular as well. And really all it is is an enhanced version of JavaScript.


Flexibility

Typescript has pretty much taken JavaScript looked at it said What's wrong with this? Added those changes and then here you go.
And the nice thing about TypeScript is that it's actually completely pretty much interchangeable with JavaScript. In fact, any TypeScript code you write can be transpired and kind of translate into native JavaScript code. So you can use any JavaScript that you already know inside of TypeScript and you can use all the TypeScript features as well. And then when it actually comes time to run this code you'll translate it into a native JavaScript file and run that.

What is TypeScript and Should you Learn it?

This is really powerful because this means that if you want to change files that are JavaScript file typescript files it's really easy to do that and vice versa. So that is where this flexibility comes from and why so many people are using TypeScript. Because it's kind of just like why not? It really just has better features than native JavaScript. 


Now TypeScript really shines in large-scale projects and enterprise-level applications.

I would say it's maybe a little bit overkill to use it for like a small side project or something where you just have one or JS files. But when you get to a point where you have a lot of structure involved in your program a lot of things going on multiple people contributing hundreds of thousands of lines of code TypeScript really shines. The reason for that is because of the features it adds to JavaScript.

So like I said if you know JavaScript you pretty much already know TypeScript. Anything you can write in native JavaScript is almost line for line. You can write the exact same in TypeScript and then the core features it adds is actually the ability to add static typing to JavaScript. So this does not change the fact that JavaScript is a dynamically typed language. And it doesn't change that when it comes to actually run this code. But it means that when you're writing TypeScript code you have type enforcement and you can choose if you want to declare the type of variables method parameters return types whatever it may be.


So the reason static typing is so important is that it comes with so many different advantages.

When you have static typing and you have type reinforcement the first thing that's a really big deal is that catching errors becomes a lot easier in a language like Python or JavaScript that's dynamically Typed. Almost all your errors are happening at runtime. Now that's not a good thing. You often don't want to get your errors at Runtime because that means first of all you have to figure out what the heck is happening at Runtime which is more complicated than before at compile time.

But there's also chances that you may miss errors because they just haven't run yet right?
In Python, you can write some random Jibbers that make no sense but it will still Compile will still run the program. And unless you actually hit that line of code you may never know that that error actually exists and the same thing in JavaScript right. Now when you have TypeScript here this pretty much eliminates I would say almost about 90% of the errors that you're commonly getting in a dynamically Typed language because now these errors are being shown to you before you can even execute the program so you have to fix them if you want to run the code you're going to see them because they're red squiggly lined in your editor.

Whereas if you're debugging something at Runtime now you probably need a debugger which you actually might not have access to. It's definitely a lot harder in my opinion to do that at Runtime because there's so many other things to consider and then you got to figure out where in your code that's actually happening from. If it's a module there's just so many possible issues when you're not catching these bugs at compile-time and when you're dealing with really large scale software that's going out to millions of people you want to make sure that you're catching all those bugs especially any detrimental ones and that you're getting them in your IDE before you actually go to the software. So that's why this is really a big deal.

The idea is if you give your IDE more information about your code it can do more work for you. And when you're in a production environment you're trying to get stuff done that's a really big deal. If you can have your IDE carry a lot of the weight do a lot of that work then you're saving yourself time and probably save a bit of money too especially if you're paying employers or whatnot to actually code. Right? You want to have them get that done as fast as possible. So that is really the core advantage to TypeScript in my opinion.

Now TypeScript comes with a bunch of other really great features too. But the one I really wanted to dial in on here is that typing. And some people might think that Oh you know it's going to be a pain. I got to declare the types. It's really not very difficult. It's optional. As I said. So you could have two people working on the same code base. One person really likes the type aspect and it's doing all of that and some person's not. And your code is still compatible and that's fine.

There may be potential issues with that of course but the idea is that it's optional. So if you're in a situation where it doesn't make sense to do that you don't have to do that whereas in other programming languages that are actually truly statically typed you would, of course, have to do that.

TypeScript is a great language. I don't see why you wouldn't learn it. It's just such an easy thing especially if you already know JavaScript. It just makes things way more powerful. And really I can't think of many disadvantages for the language. And I'm someone who doesn't really like JavaScript in front and programming in general. And the only thing I've seen online is the fact tha


Last words

So in my opinion TypeScript is really just a superior language to JavaScript. I don't really see any scenarios where I would use vanilla JavaScript over TypeScript especially now that I know TypeScript it doesn't take very long to learn. It's pretty easy to get used to. And I would say for any of you reading this if you know JavaScript why not just go ahead and learn TypeScript. It's a great language to add to your resume. It shows that you're keeping up with trends that you know about the new languages and it's something that most people probably aren't learning right now or probably don't know.

I can be wrong on that. But from the people I've talked to from people in my CS courses as I am still in University, I don't really know any of them that are learning or using TypeScript unless they have an internship or they're actually working in the industry. And it seems like that could be something that gives you a little bit of an advantage if you're going for a job or if you're just looking to get into new technology.

So anyway I know this has been a short article but I just wanted to make you guys aware of the typescript as I've been using it for the past few days and I thought it was an awesome language. I hope you found this article helpful make sure to leave a comment and also share it with others.

Post a Comment

0 Comments

class='back-top' title='Back to Top'/>