Comment by bil7

2 years ago

My least favourite thing about vanilla JS is finding out at runtime that I made a typo. That's an annoying thing that TS completely solves, among many others. I really don't see how you could use TS for any amount of time and wish to revert back.

>Things that should be easy become hard, and things that are hard become `any`. No thanks!

Denouncing a type system because you refuse to use it correctly seems short sighted to me, but I am of course biased as a TS fan.

I often wonder if people who have trouble typing things, or have to us the 'any' type, ever really learned how to program.

  • Yep, when I hear people say things like "I like $dynamic_language because I don't have to think about what types I'm supposed to put when I write my functions" or similar, I'm just thinking "how the hell can you write a function without knowing what types you want to receive and return?". I do love the "productivity benefits" of having to read entire function bodies to reverse-engineer what types I'm supposed to pass, because the docstring just used vague terms like "file" or "user"

  • I find that areas that are hard to type are a code smell indicating potentially unstable API design. It can be pretty tricky adding types to a JavaScript project as the lack of types can lead to some very side effecty apis that can be very difficult or impossible to add full type safety to.

    My impression is that people running into these problems are trying to add declaration files to JavaScript code, but if you use typescript throughout I've not run into these problems.

    Anything I find hard to type is simply a hard problem to solve in the first place and the type system helps me rethink the problem to find safer and more elegant API designs.

  • So the only real way to learn how to program is to learn typed programming?

    Meaning you could create most modern applications (including this very website) without really learning to program...

    Fun perspective.

    • Learn to program [at a high level]. Which means being able to write code with a type checker in a way that makes you faster not slower at producing high quality, maintainable programs.

  • any (concept not keyword) is useful when you NPM install something without types and just do a define module in a local .d.ts. You are implicitly any-ifying that package.

    • I'm referring to people who get frustrated and use 'any' as an escape. Especially in programs they write themselves. That's just incompetence.

      1 reply →

  • Probably true. After 30 years of writing code, I guess I just haven't figured it out yet.

    Thankfully you and Typescript are here to show me how to do it right.

    • Years of experience don't mean much, if you just repeat the same thing over and over again and aren't willing to learn new things and reevaluate your workflows.

      I have seen people with decades of experience who remained stuck doing things the same way they first learned to do them and refusing to adapt.

    • What languages have you written for 30 years? and what about TypeScript is so challenging for you? Especially if you’ve already spent time with other statically typed languages.

I felt similarly. But ultimately, TS is there to solve a particular set of problems, and if they're able to solve their problems without it, more power to them I guess.

The benefits of typescript when refactoring is immense. I have a really hard time understanding how someone could not see the net productivity gain if they've experienced refactoring in typescript vs JavaScript.

  • > I have a really hard time understanding how someone could not see the net productivity gain if they've experienced refactoring in typescript vs JavaScript.

    cause I spend more time debugging other peoples typescript code that is usually a typescript problem and is obfuscated by the extra layer. If we used vanillaJS then it would save everyone so much time.

It's not a Type System denouncement, it's denouncement of crappy TS and that's the right choice.