Live data from Hacker News

Ask HN: Is TypeScript worth it?

news.ycombinator.com

241–250 of 469 posts

Re: Ask HN: Is TypeScript worth it?

#241
I think you are asking the wrong question. The right question is whether it is worth opting out of the benefits of typescript. The answer to that is probably no for lots of people. Another valid question to ask is if typescript is all there is when it comes to those benefits. And the question to that is also no. It's a nice step up from Javascript. But why stop after that? There are so many other languages out there that offer so much more. And some of them even transpile to javascript.

Regarding your points:

I) this is indeed endemic in the javascript world. I would not blame typescript for this. I work with Java and Kotlin a lot. Things are more stable there. Five years is short for compatibility. In the js world, six months is long.

II) The typescript annotations are documentation too. They help your IDE figure out what is what and enable things like autocomplete. The original js code probably isn't a whole lot better. Also, lots of libraries are developed in typescript these days.

III) That's what happens in weakly typed and highly asynchronous environments. Pure javascript just moves that burden to runtime. Better to deal with it before you deploy your code.

IV) Most modern javascript is transpiled. It's a compilation target at this point. So you might as well make full use of the fact that there is a compilation step. The packaging and minification is actually just as bad.

Re: Ask HN: Is TypeScript worth it?

#242

Earlier quoted context omitted.

> TS saves me time every day. Hmm, not my experience. I do TS for years now and still today I'm spending more time on fighting/pleasing TS compared to the actual code. JS with all its node_modules dependencies is a complete nightmare to get the typing right. I regularly have to change good solid code to please TS, but at the same time TS often doesn't complain when the typing is obviously wrong. I once started with A…

What's Math.sqrt("hello")?

[flagged]

Re: Ask HN: Is TypeScript worth it?

#243
post #234
post #214

Is it worth it compared to what? Plain JS? Transpilation from a different language? Rust? Growing apples? I have used plain JS, GWT, and TypeScript. TS is an incredible improvement over the two others. The TS type system is excellent, very expressive and helpful. An important advantage you get from static typing is that your IDE has more information to work with and so becomes more powerful. If you code in a text edi…

try out dart, its much better than TS

Is Dart object oriented language? What is its roadmap? I know it was created by Google, but is it replacing js?

Re: Ask HN: Is TypeScript worth it?

#244

Earlier quoted context omitted.

> TS saves me time every day. Hmm, not my experience. I do TS for years now and still today I'm spending more time on fighting/pleasing TS compared to the actual code. JS with all its node_modules dependencies is a complete nightmare to get the typing right. I regularly have to change good solid code to please TS, but at the same time TS often doesn't complain when the typing is obviously wrong. I once started with A…

What's Math.sqrt("hello")?

Or 5/"potato"

In JS it's NaN, in TypeScript (or any other language with a remotely sane type system) it's a compilation error that saves you from running into a random NaN at runtime.

Re: Ask HN: Is TypeScript worth it?

#245

Earlier quoted context omitted.

What's Math.sqrt("hello")?

[flagged]

So then you have to make sure any inputs that get passed into Math.Sqrt aren't strings. You can pay the cost at runtime or compile time, and doing it at compile time saves you headaches later.

Re: Ask HN: Is TypeScript worth it?

#246
Typescript is great but be aware that sometimes it can annoyingly slow you down. Consider these scenarios:

- You want to use a third party library but it is completely untyped - You need an object but you're just prototyping it. You don't yet know which keys will be optional - You type a key of one of your objects. Now you load or fetch data from an API and want to assign that to it. But typescript complains because the promise can also return undefined. - and many more

Just be aware that it will annoy you at times.

Re: Ask HN: Is TypeScript worth it?

#247
Couple of years working with TS and I think I can add my 5 cents here:

1. It is worth it, but not as much for benefit of types safety straight forward as for ... "intellisense" that discharge you from remembering stuff and misspelling it

2. It is annoying - they (MS/TS team) have very "conservative" approach which leads to:

  - no operators overloading, 
  - no option to extend primitive types, 
  - no option to get info about your types at transpile time, 
  - no built in options to improve performance at transplantation time,
  - no built in options for transformation plugins
  - no other than JS transpilation targets
  - need of tons of other tools to make your actual target, 
  - ... etc. 
At the end it does job well, but only because you put in it a lot of man hours (to learn, develop and maintain) - and everyone seem to be happy about that.

Sorry for being a bit grumpy, but sometimes it feels like wasting a life working with TS. ;-) (especially when I read again what I just wrote ;-) )

Seriously, let me know MS/TS team if you need someone to drive to TS some real fresh new value ;-)

Re: Ask HN: Is TypeScript worth it?

#248

Earlier quoted context omitted.

What's Math.sqrt("hello")?

[flagged]

I agree that is not a good example, but the exact same thing can happen in more subtle ways that is hard to catch. For instance you might have a function that returns a user. Do you pass in the user ID argument as a string or a number?

Re: Ask HN: Is TypeScript worth it?

#249
You can't believe from how much bugs TypScript has saved me. When it was "first released" (when it became more popular), I have ported our starter kit to TypScript and was amazed on how much stuff it was detecting as not safe.

Since then, I can't image working without TS. As for Third Party libraries, I have a different experience from other devs here, it works very well for most (if not all) big libraries/frameworks, and the autocomplete saves me so much time in digging in the docs.

Re: Ask HN: Is TypeScript worth it?

#250

Earlier quoted context omitted.

Thanks for your work, TS saves me time every day. I was saying something similar to the op 3-4 years ago but really cannot picture working without some kind of type safety in JS now.

> TS saves me time every day. Hmm, not my experience. I do TS for years now and still today I'm spending more time on fighting/pleasing TS compared to the actual code. JS with all its node_modules dependencies is a complete nightmare to get the typing right. I regularly have to change good solid code to please TS, but at the same time TS often doesn't complain when the typing is obviously wrong. I once started with A…

I’m noticing a pattern in your arguments.

You need to understand that I (and I suspect many others) don’t have the same experience as you. I don’t _fight/battle with_ the type system, I work with the type system - and I enjoy it. It saves me countless hours. I don’t actually use javascript without TypeScript anymore - it’s simply not worth _not_ using it - for me.

You ask whether it’s worth using it - and you keep telling people not to explain the primary benefits to you. The answer is yes for many people. It seems like you’re looking to be convinced that it’s worth it but you don’t want anyone to tell you what you already know. I’ve done this myself in the past - I’m not saying the situation is the same for you but it might be worth looking inside at: when I did this it was because I knew that x was worth it but I’d put myself in a position where getting down off my hill and accepting that x was worth it would require me to admit that I’d been wrong about it. Now I could double down on my position that x was simply not worth it, or I could come down slowly and start to enjoy the benefits of x more openly.

If you kinda feel that what I’ve just said might be a factor for you, then that’s already incredibly brave. If you’re interested in taking it further I can recommend role playing: for a week (just a week) role play as someone who thinks x _is_ worth it. Adopt the positions on the benefits that you already know. Act like you love it, act like the type checker REALLY helps you and saves your time, act like the types aren’t all that bad and CAN be used in usefully-constricting ways, and of course, help make your code even more self-documenting. You’ve gotta convincingly act, as if you’re going to win an Oscar. The audience fully believe you’re a true, light-seeing advocate for x.

Being able to change your mind is a great, noble and immensely valuable skill, and I can see that’s what you’re trying to do. Consider role playing as an advocate like I suggested above and perhaps you’ll have a new tool in your toolbox.

Post reply on HN