3 ms·
Does it make sense though? What should happen if a type hints a string and there’s a number in a received json? We gonna segfault?
by wruza 2y ago
Does it make sense though? What should happen if a type hints a string and there’s a number in a received json? We gonna segfault?
- Waterluvian 2y agoYeah, exactly. You would need to handle deserialization like all the other strong/static languages. It would be an extra constraint for an extra layer of guarantee and ideally performance.
- wruza 2y agoI see, good point. Although my feeling is that typescript’s idea of a type system living on a separate plane was one of the greatest ideas of all time. Never felt so good about something that is basically js. With strict semantics like Rust/C++/Zig/Go it would be just a weaker clone of those with all the usual strings attached.
- Waterluvian 2y agoOh I fully agree. The ability to turn the type system off when you’re testing or hacking and want to be quick, or to gradually type a JavaScript project… it’s really the best. But I’ve got projects that are now as “correct” as possible, with full validation at deserialization and such and I just wish a compiler could take things an extra mile.