Live data from Hacker News

How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

chiragswadia.medium.com

161–170 of 400 posts

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#161
Short article, felt like what has been said before numerous times. I will opine why I was hesitant at first. The biggest reason was I didn't want to start writing a bunch of not-js (as in not a "strict superset" of js) and also having to deal with writing my own type definitions. I remember trying things like flow and reasonml and got quickly annoyed bending over backwards to use non-reason/flow code.

It seems like as of 2021 though that typescript has sort of won and the community has done great work in covering virtually every package I seem to use. npm helpfully points out which libraries have typescript definitions or a @types/. I'm still not entirely sold on the strengths of strong typing in terms of bug avoidance, but the IDE like features are enormous. For me personally I see typescript more as a forced, never stale or mostly-incorrect, JSDoc.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#162

For me, I can handle the lack of static typing when I'm doing small scripts, like if it's going to be 100 lines or so of Python (my go-to language if I need to test some math out in a sandbox or do some file manipulation on my system). I might actually be a little faster in writing those scripts because of the lack of typing. Once it starts getting any bigger than that, though, static typing really catches and points…

I use type annotations in Python no matter what. It really helps skim the code faster and mentally understand what values I am expecting. Its very useful to know which var is a List[dict] and so on.

I don't like TS because javascript is just a silly language to do anything serious with (besides front end), and its so stringent it takes forever to write quickly.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#163
Still not a typescript fan here. It feels like a half-baked language because of the insistence of not having a runtime (even though some information makes it through to the underlying js...so this objection of theirs isn't total). In a usual typed language, you could extract the type of an intersection type using pattern matching. But you can't do that in typescript. Instead you get to pick the most relevant ugly hack for your situation.

Typescript feels like every one of its features has some catch, and it's very irritating.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#164
post #122

It's probably worth taking a step back and interrogating why the actual "Why was I Anti-TypeScript?" a little bit more and use it as an opportunity for broader self development. The author didn't use and understand something, and rather than trying to they instead just defaulted to rejection. It's midly disapointing seeing this in people who label themselves as "Senior".

Ironically, as someone who has experience w/ both fast-and-loose JS and with "properly" statically typed languages, my beef with typescript is precisely that it allows people to be fast and loose, sometimes in ways that are not super obvious. For example: type Thing = { name: string, }; function getThing(): Thing { return JSON.parse('{"error": "invalid id"}') } const thing: Thing = getThing(); // lie to me! console.l…

> (e.g. people wasting hours trying to write a "function" that takes an enum and outputs another enum w/ a fixed prefix...

Metaprogramming shouldn't suck so much that this takes hours.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#165

Still not a typescript fan here. It feels like a half-baked language because of the insistence of not having a runtime (even though some information makes it through to the underlying js...so this objection of theirs isn't total). In a usual typed language, you could extract the type of an intersection type using pattern matching. But you can't do that in typescript. Instead you get to pick the most relevant ugly hac…

It takes a lot of mental and emotional capital in the creative process to produce something that is truly wonderful. Microsoft is systemically incapable of approaching creative perfection. Very few are.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#166
post #154
post #122

Earlier quoted context omitted.

Ironically, as someone who has experience w/ both fast-and-loose JS and with "properly" statically typed languages, my beef with typescript is precisely that it allows people to be fast and loose, sometimes in ways that are not super obvious. For example: type Thing = { name: string, }; function getThing(): Thing { return JSON.parse('{"error": "invalid id"}') } const thing: Thing = getThing(); // lie to me! console.l…

This particular example is close to my heart: the definition files for things like JSON.parse() were written before the "unknown" type was introduced as an alternative to "any" And because this "any" is coming from an external definition file, it can't be caught by tsc's --noImplicitAny nor eslint's no-explicit-any Those two rules allow us to protect us from our own code, but not external definitions/libraries. Relev…

Looks like eslint is working on a new set of rules that would help with these currently-unprotected any cases: https://github.com/typescript-eslint/typescript-eslint/issue...

> Create a rule which uses type information to determine when you're inadvertently breaking type safety by using an any, potentially without knowing.

> Often libraries (or even the typescript defs themselves) can have weak(/lazy) types which return any. If you're not careful, you can inadvertently introduce anys within your codebase, leading to bugs that aren't caught by the compiler.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#167

Earlier quoted context omitted.

I think the skepticism of new shiny things is healthy. Of the set of things that exist, most things are worse than the things one already uses/prefers. Most new things solve a specific problem that may not overlap with the problems one is trying to solve. With software development, a huge part of the puzzle is tooling (as the article points out), so even if typescript is obviously superior as a language, the tooling…

Being skeptical shouldn't mean being ignorant. Being skeptical should mean Trying to understand the pros and cons and believing it's not worth it.

Or alternatively waiting it out a bit until it's more obvious what the pros and cons are (because others have tried it out in depth and shared their experience). Still a far cry from actively dismissing it.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#168

I think a large part of the support for Typescript comes from being able to create good tools for the language. But, I still have an aversion to front-end development itself, because it just feels too _involved_. You have to set up so much, and it has become a lot more difficult since you need to install webpack, postcss, and many other plugins just to do a hello world app. It's still bearable if you have to do all o…

I've spent the last two years writing my own framework because I hated React so damn much.

It really doesn't have to be that complicated. Granted, I still use a bundler, but it's really easy to set up. I had my friend walk through it all... he seems to think it's great.

I should probably release this project some day.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#169

Still not a typescript fan here. It feels like a half-baked language because of the insistence of not having a runtime (even though some information makes it through to the underlying js...so this objection of theirs isn't total). In a usual typed language, you could extract the type of an intersection type using pattern matching. But you can't do that in typescript. Instead you get to pick the most relevant ugly hac…

The issue that broke the camel's back for me was when I saw "cstomerName is not defined" in production. I just could not accept that it is OK to live with tools that let that happen.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#170
post #14

Earlier quoted context omitted.

The heuristic of "new JS tech is just needless complexity/over-engineering" is not a bad one to have in the JS ecosystem imo :)

That's my personal heuristic and why I continue to reject TS just like I avoided coffee script, flow, clojurescript, and so on. But this article reads like "Developer who only used dynamic typing learns about static types." You could sub in any two such languages and get the same article.

One of the things you listed is not like the others. Why didn't you give Clojurescript a chance. It's like being in Hell and then someone brings you infinite amounts of cold fiji water. Hell becomes more bearable ;)
Post reply on HN