Hacker News new | ask | show | jobs
by jupp0r 1204 days ago
Have you ever used a language where types can influence runtime behavior? It's an extremely powerful tool to do things like choosing a specialized sort algorithm based on the type of contents of array you are sorting. This has zero overhead iff types are known at compile time and can yet hit different code paths at runtime. To just dismiss this as not needed is extremely short sighted in my opinion.
3 comments

Having types at runtime is a big deal and I lament that typescript can’t do it (for understandable reasons.)
I have. And I think the limitation is good for a language that doesn’t have that. I don’t want TypeScript to lie to me about its capabilities, I want it to help me make good decisions with the runtime code I actually have.
You can always use zod or io-TS.