by nathan_phoenix on 4/12/25, 4:01 PM with 71 comments
by webdevladder on 4/12/25, 6:00 PM
I've been evaluating schema libraries for a better-than-Zod source of truth, and ArkType is where I've been focused. Zod v4 just entered beta[1], and it improves many of my problems with it. For such a mature library to improve like this, v4 is treat and speaks volumes to the quality of engineering. But ArkType has a much larger scope, and feels to me more like a data modeling language than a library. Something I definitely want as a dev!
The main downside I see is that its runtime code size footprint is much larger than Zod. For some frontends this may be acceptable, but it's a real cost that isn't wise to pay in many cases. The good news is with precompilation[2] I think ArkType will come into its own and look more like a language with a compiler, and be suitable for lightweight frontends too.
by Aeolun on 4/13/25, 4:07 AM
It’s a miracle it can be 100x faster than Zod, but speed was never my issue with zod to begin with.
by alganet on 4/13/25, 12:04 AM
If you mess that (either by being too flat, too customizeable or too limited), library users will start coming up with their own wrappers around it, which will make your stuff slower and your role as a maintainer hell.
(source: 15 years intermittently maintaining a similar project).
There is an obvious need for a validation library nowadays that bridges oop, functional and natural languages. Its value, if adopted as a standard, would be immense. The floor is still lava though, can't make it work in today's software culture.
by brap on 4/12/25, 9:50 PM
by Chyzwar on 4/12/25, 6:01 PM
by madeofpalk on 4/12/25, 6:33 PM
There’s a few tools out there that generate code that typescript will prove will validate your schema. That I think is the path forward.
by chrisweekly on 4/12/25, 6:58 PM
by domoritz on 4/12/25, 6:35 PM
by t1amat on 4/13/25, 3:30 AM
by cendyne on 4/12/25, 7:10 PM
by cugul on 4/12/25, 7:48 PM
https://developer.huawei.com/consumer/en/doc/harmonyos-guide...
by tomaskafka on 4/13/25, 12:44 PM
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?"
Me: "What?"
Realizing this was a true facepalm moment for me. No one ever thought of adding a debug TS mode where it would turn
function myFunc(a: string, b: number) {}
into
function myFunc(a: string, b: number) { assert(typeof a === "string") assert(typeof b === "number") }
to catch all the "somebody fetched a wrong type from the backend" or "someone did some stupid ((a as any) as B) once to silence the compiler and now you can't trust any type assertion about your codebase" problems. Nada.