Live data from Hacker News

ArkType: Ergonomic TS validator 100x faster than Zod

arktype.io

71–72 of 72 posts

Re: ArkType: Ergonomic TS validator 100x faster than Zod

#71
post #63

TS: "We have added types to javascript, everything is now strongly typed, and the compiler will pester you to no end until it's happy with the types." Me: "Awesome, so I get an object from an API, it will be trivial to check at runtime if it's of a given type. Or to have a debug mode that checks each function's inputs to match the declared types. Otherwise the types would be just an empty charade. Right?" TS: "What?"…

That isn’t what TypeScript is for, you’re describing a similar but unrelated problem, namely runtime type validation. There’s a reason why JSON.parse() returns any. However. TS allows to avoid logical errors in the program's source, which is a class of errors historically very important, since JavaScript is so highly dynamic. The debug mode sounds interesting at first thought, but quickly explodes in complexity when…

> "The debug mode sounds interesting at first thought"

I don't think so. I just added typia's is* checks to places where I am digesting a json input, it was rather trivial, and now I can actually trust for the first time that the object I am holding actually matches the declared type.

> "You can’t make things idiot proof"

I just did. You can't have a non-idiot-proof program running in the wild and blindly trusting the outputs of whatever API it uses.

Re: ArkType: Ergonomic TS validator 100x faster than Zod

#72
post #63

Earlier quoted context omitted.

That isn’t what TypeScript is for, you’re describing a similar but unrelated problem, namely runtime type validation. There’s a reason why JSON.parse() returns any. However. TS allows to avoid logical errors in the program's source, which is a class of errors historically very important, since JavaScript is so highly dynamic. The debug mode sounds interesting at first thought, but quickly explodes in complexity when…

> "The debug mode sounds interesting at first thought" I don't think so. I just added typia's is* checks to places where I am digesting a json input, it was rather trivial, and now I can actually trust for the first time that the object I am holding actually matches the declared type. > "You can’t make things idiot proof" I just did. You can't have a non-idiot-proof program running in the wild and blindly trusting th…

I doubt you're able to catch all edge cases even in your own program (in an economically viable way), but great for you if that works for that use case.

However, if we're talking about the TypeScript compiler, the complexity required to ensure end-to-end runtime type soundness is orders of magnitude greater than sprinkling a bunch of isString checks here and there.

Post reply on HN