News for hackers. Stuff that matters.
Re:Rewriting TypeScript in Rust? You'D have to be by Zaskoda on Wednesday December 14, 2022 @12:29PM (#33986750)
I find this comment validating. Most of the languages I've used start to click and feel good after a while - but it feels like this just won't happen for me with typescript. I'm clearly missing some fundamentals and I'm not even sure what it is I need to go study.
Re:Rewriting TypeScript in Rust? You'D have to be by soiler on Wednesday December 14, 2022 @01:08PM (#33987283)
Can you explain why you feel that way? I only know JS and TS, and I love TS. With both languages, I understand I'm missing out on a lot, but I kind of assumed that was normal with my level of study (that is, reading in depth to fix bugs or make new features, and generally no further).
Re:Rewriting TypeScript in Rust? You'D have to be by evandwight on Wednesday December 14, 2022 @01:04PM (#33987231)
What doesn't click? I've found it pretty intuitive, though I've explicitly avoided making complicated types.
Re:Rewriting TypeScript in Rust? You'D have to be by randomdata on Thursday December 15, 2022 @12:14AM (#33995519)
The type erasure. You get this nicely expressive type system that can encode all sorts of useful metadata, and then you have to recreate it all again by hand in 'Javascript' to access it at runtime.

Say I have `type Foo = 'bar' | 'baz'` and want to validate that an input string is within the set of Foo. Why can't I just enumerate the type to determine the valid values at runtime?

Re:Rewriting TypeScript in Rust? You'D have to be by scotty79 on Thursday December 15, 2022 @05:01AM (#33997387)
For me it's a great feature because it means that the code has purely javascript semantics not influenced by andy generic type magic that happens on compile time.

Occasionally I bump in the same things as you when I'd like to have some JS code generated on the basis of TS type information. I think there could be some preprocessing tools that could generate JS validators on the basis of TS code.

Now, trying Rust I strongly appreciate this separation. In Rust what your code DOES might depend on what you are going to do in the future with the result it returns. It's really shocking for me and makes finding errors really hard when the spot of the error messages jumps wildly across large chunk of your code as I change it.

I really prefer TS philosophy of "types are for you and your text editor and the actual code is for runtime".