3 ms·
Yes but once the json has been validated once at runtime, you know it's safe for the rest of your program to use. Whereas in a dynamic language (even an immuta
by GeneralTspoon 7y ago
Yes but once the json has been validated once at runtime, you know it's safe for the rest of your program to use.
Whereas in a dynamic language (even an immutable one), your data could be mutated during program runtime and no longer conform to the type you expected. Yes you could re-validate it everywhere, but that requires you to exercise every code path when testing at runtime to find bugs.
I think the general argument that "You can't static type everything (like your API dependencies), so there's no point in doing it all" isn't a very solid one.
- int_19h 7y agoYour data can't be mutated if you're using immutable data structures. Which is what Clojure defaults to, in fact.
- GeneralTspoon 7y agoI didn't mean literally mutating the same structure in place - but a new version of your data structure could be returned from a function which changes some of the keys/values in unsafe ways.