A few days ago, David Heinemeier Hansson
announced
that Turbo 8
is dropping TypeScript
. I'm okay with that because I don't even know what Turbo 8 is. However, over the past few years, some frontend programmers have tried to sell me the idea that "TypeScript is useless, just use tests". I think people with such opinions either don't care about code quality or simply don't know what TypeScript is. Here, I will explain why you should use TypeScript.
Reading the responses here, why are people so mad about types? Maybe I’m biased coming from a background of statically typed languages and mathematics. I’d rather have a good typing system that makes me think about data than just hoping I’ve thought about a problem right.
So not typescript then.
I’m half joking, but the problem with typescript is that it’s JavaScript with types. The industry needs to stop retrofitting types to dynamically typed languages. The type system is an intrinsic part of the language design and if you’re going to have it, it should be there from day 1. Being dynamically typed wasn’t a language bug. It is a feature designed for a certain class of problem. I’m sure 90% of proponents only want it so they get better completion in their IDE, but I personally think it makes a lot of code far more difficult to read.
I have valid criticisms of statically typed languages, based around code patterns that are both expressive and efficient that are either difficult or impossible to implement in a statically typed language without “an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.”
Typescript, however, is different. Its type annotation functionality is not the same as a static type system, which means I get to keep all those things I like about dynamically typed languages while still having compile-time validation.
Flip-side, however, is the complete lack of runtime validation in typescript, and the fact that junior developers trip on that a lot. I would call that a real advantage of javascript (if not enough to stop me from using Typescript). Having no check at all is better than being convinced typescript is protecting you when it’s not.
I dunno. I think it is people don’t want to think about their code and what they are asking the computer to -actually- do. I’ve had to fix more issues due to incorrect assumptions that were allowed / looked OK in JS that would have been easily seen and/or prevented in TS (or any strong static typing system). Yes, TS may be annoying, but there are -reasons- it is. If you’re asking it to do something that is innately dumb, TS makes it -HARD- to do it, so you manage a large majority of the potential use-cases that you may not know you’re asking the runtime to manage/assume for you.