News for hackers. Stuff that matters.
Re:Functions and algorithms implemented purely with TypeScri... by jongjong on Wednesday July 05, 2023 @08:21AM (#36599365)
I disagree, my point is that my code is better if I write it as JavaScript. TypeScript is more like an extra unnecessary thing I need to do which doesn't add any value.

A better metaphor would be; I want to boil some chicken to make a healthy dish and I have a pan full of boiling water... Then just as I'm about to put the chicken inside, the head chef stops me and tells me that I need to pour oil into the pan.

I protest; "But sir, there's no need, I'm making boiled chicken, not fried chicken... This isn't KFC."

"Do as I say" says the head chef.

So I reluctantly pour some oil on top of the water, then I add the chicken. It splashes around a bit, no big issues, and the chicken comes out OK; slightly of greasy but not noticeable after adding the seasoning...

"See, it all worked out, aren't you glad you listened to me?" says the head chef.

Re:Functions and algorithms implemented purely with TypeScri... by goda90 on Wednesday July 05, 2023 @08:41AM (#36599587)
In what ways would writing things the Typescript way make your code worse than the JavaScript way? I can't imagine the typing system preventing me from doing things that are better, other than cases where I want more expressive typing itself, which isn't even applicable to JavaScript.
Re:Functions and algorithms implemented purely with TypeScri... by SketchySeaBeast on Wednesday July 05, 2023 @09:04AM (#36599869)
This metaphor is all wrong. If we're going to stretch cooking, TypeScript is the recipe book. While cooking it seems you would prefer to write "add bit of something savoury", when you really mean "1 tbsp Worcestershire". TypeScript's greatest strength is in the next person being able to pick up the component and being able to run with it, or you being able to replicate it again in three months.

If you start by just throwing all the crap you want into a pot and afterwards try to remember what you added and how long you cooked it for of course it's going to be a lot of extra work. TypeScript requires a methodical approach which over the long run makes it easier for the entire kitchen.

Re:Functions and algorithms implemented purely with TypeScri... by madeofpalk on Wednesday July 05, 2023 @12:18PM (#36602606)
Completely valid - if you don't see value in a tool, don't use it.

But parent is saying that you should recognise that you're opting yourself in for a harder time by ignoring typescript at the beginning, and then trying to retrofit your way into type safety. That's definitely going to be more difficult and frustrating.

So either don't use typescript (which is fine fine - no one here cares about the programming language you use), or, use it 'properly' from the beginning and work with the tools you're using rather than against it.

Re:Functions and algorithms implemented purely with TypeScri... by chezelenkoooo on Wednesday July 05, 2023 @06:02PM (#36607794)
Maybe your code is ok and understandable to you when you first write it, but when someone else has to work on it a month or two later, a lack of types makes it significantly more difficult.

It sounds like your process is a bit of a drag on you and I think you should improve it.