Check out a free preview of the full Deep JavaScript Foundations, v3 course

The "Static Typing Pros" Lesson is part of the full, Deep JavaScript Foundations, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Kyle discusses benefits of static typing.

Preview
Close

Transcript from the "Static Typing Pros" Lesson

[00:00:00]
>> Kyle Simpson: So to understand that thing that I would like there to be in the middle, the all or nothing sort of conundrum that we're facing, I wanna dig into those pros and cons a little bit more specifically. These are just my takes on the pros and cons, this is not some objective list.

[00:00:15]
Number one, I think one of the big pros about systems like TypeScript and Flow, I said this earlier, they make the types much more obvious in your code. And that's a big improvement. A big improvement over writing code that's essentially completely uncertain, unascertainable what's gonna happen with this particular operation.

[00:00:37]
Making those types obvious is a good thing. It's also a very strong positive that the design of TypeScript and Flow, to put a pun here, goes with the flow, if you will, of the way static typing works in a lot of other languages. The syntaxes are very similar.

[00:00:57]
And so there's a strong sense of familiarity. When you show up to something like that, you're not in this entirely different world than you've ever done with types before. It feels very much like the types that you have from a more typically typed language, like a Java or C++.

[00:01:14]
So the familiarity is a strong pro, and I'm sure that was part of their design. They are extremely popular. It's undeniable the popularity, especially of TypeScript. It seems like everyday we get an announcement of some new major open source project that's completely converting over to TypeScript. And just like the hype curves that build up in the community behind something like a React or a Vue, they've built up in such a strong way, with a big backing, TypeScript being from Microsoft, Flow being from Facebook.

[00:01:46]
They've built up in such a big way with the community and the corporate support behind it, that the investment to learn and get into one of those is gonna be an investment that pays off for a long time. It's not some fad that's gonna go away next week.

[00:02:00]
So the popularity is a strong suit. There's a big community behind it, a ton of documentation, a ton of momentum behind these projects, and it certainly does make sense. In fact, I would absolutely say, whether I liked TypeScript or not, it would be silly to me for you to be working in a system, say you worked in a Microsoft .NET shop and you wrote C# all day on the backend, and then you needed to do some JavaScript.

[00:02:25]
I can't imagine a scenario where you wouldn't use TypeScript. Cuz the mental context switching of, I've been in types world and now I'm in non-types world, would be nuts to me. So there's lots of scenarios where it makes completes sense. And the popularity of that, that's the reason why it's growing.

[00:02:42]
And they're very sophisticated, and that makes them really good at what they do. I'm actually kind of amazed at how much something like TypeScript or Flow can infer from code that I even intentionally try to obfuscate, and they're still able to figure those things out. These tools are fantastic at that.

[00:03:02]
So these are all strong pros, but I also have some strong negatives against them.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now