Live data from Hacker News

ArkType: Ergonomic TS validator 100x faster than Zod

arktype.io

31–40 of 72 posts

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

#31

Earlier quoted context omitted.

We use it heavily for backend code, and it is a bit of a hot path for our use cases. However the biggest issue is how big the types are by default. I had a 500 line schema file that compiled into a 800,000 line .d.ts file — occupying a huge proportion of our overall typechecking time.

That sounds absolutely absurd. Are you using a lot of deeply nested objects + unions/intersections?

A fair number of unions, yeah. Which also means some of the tricks for keeping the types small don’t work —- ie taking advantage of interface reuse.

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

#32

Earlier quoted context omitted.

Runtime validation is strictly necessary across data boundaries that consume user input.

Sorry, I was unclear. Using a library like zod requires you to trust that Zod will correctly validate the type. Instead, I much prefer to have schema validation code that typescript proves will work correctly. I want the build-type checks that my runtime validation is correct. Typia generates runtime code that typescript can check correctly validates a given schema https://typia.io/docs/validators/assert/ . I've neve…

Using a library like zod requires you to trust that Zod will correctly validate the type.

Not sure I understand this -- are you assuming there’s an existing schema, either a TS type or maybe something else like JSON Schema, and you’re trying to ensure a separate Zod schema parses it correctly?

The usual way to use Zod (or Valibot, etc) is to have the Zod schema be the single source of truth; your TS types are derived from it via z.infer. That way, there’s no need to take anything on trust, it just works.

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

#33

ArkType is a really interesting library that has a difficult time marketing itself. More than being a schema validator, it brings TS types into the runtime, so you can programmatically work with types as data with (near?) full fidelity. 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 w…

I recently went down this same rabbit hole for backend and stumbled on Typia[0] and Nestia[1] from the same developer. The DX with this is fantastic, especially when combined with Kysely[2] because now it's pure TypeScript end-to-end (no runtime schema artifacts and validations get AOT inlined).

I was so shocked by how good this is that I ended up writing up a small deck (haven't had time to write this into a doc yet): https://docs.google.com/presentation/d/1fToIKvR7dyvQS1AAtp4Y...

Shockingly good (for backend)

[0] Typia: https://typia.io/

[1] Nestia: https://nestia.io/

[2] https://kysely.dev/

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

#34

With many TS features making their way into JS, I've sometimes wondered if TS is to JS what Sass is to CSS. I currently rely on TS, but I now consider Saas harmful [there being overlapping syntax w/ vanilla CSS].

What features are you thinking of? I hadn’t heard anything about TS types making their way into JS in any way (unless you count engines that can execute TS directly, but those just ignore the type syntax). That would be a massive change.

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

#35
post #3

V4 of zod landed recently and it promises better perf https://v4.zod.dev/v4

I really want to see the people that have performance issues with Zod and what's their use case. I mean it. I've been parsing (not just validating) runtime values from a decade (io-ts, Zod, effect/schema, t-comb, etc) and I find the performance penalty irrelevant in virtually any project, either FE or BE. Seriously, people will fill their website with Google tracking crap, 20000 libraries, react crap for a simple cru…

Zod is the default validator for https://github.com/gajus/slonik.

Zod alone accounts for a significant portion of the CPU time.

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

#36

ArkType is a really interesting library that has a difficult time marketing itself. More than being a schema validator, it brings TS types into the runtime, so you can programmatically work with types as data with (near?) full fidelity. 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 w…

I recently went down this same rabbit hole for backend and stumbled on Typia[0] and Nestia[1] from the same developer. The DX with this is fantastic , especially when combined with Kysely[2] because now it's pure TypeScript end-to-end (no runtime schema artifacts and validations get AOT inlined). I was so shocked by how good this is that I ended up writing up a small deck (haven't had time to write this into a doc ye…

I was going to ask about how pure types would fill the gap for other validations in Zod like number min/max ranges, but seeing the tags feature use intersection types for that is really neat. I tried assigning a `string & tags.MinLength` to a `string & tags.MinLength` and it's interesting that it threw an error saying they were incompatible.

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

#37
In validation, it's never about speed. Is how you relate the schema tree to the error reporting tree. If you didn't already, you will figure that out eventually.

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.

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

#38
post #6

Earlier quoted context omitted.

> The main downside I see is that its runtime code size footprint is much larger than Zod. Yes, it unfortunately really does bloat your bundle a lot, which is a big reason I personally chose to go with Valibot instead (it also helps that it's a lot closer to zods API so it's easier to pickup). Thanks for linking that issue, I'll definitely revisit it if they can get the size down.

Personally, I find Zod’s API extremely intimidating. Anything more resembling TypeScript is way better. ArkType is neat, but ideally we’d have something like: export reflect type User = { id: number; username: string; // ... }; Edit: just remembered about this one: https://github.com/GoogleFeud/ts-runtime-checks

This is why I like libraries like typia or typebox-codegen; I'd prefer to write TypeScript and generate the validation, rather than write a DSL.

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

#39
post #24

Earlier quoted context omitted.

Could you give an example or two of “more than that”?

Yeah, you can walk the AST of your types at runtime and do arbitrary things with it. For example, we're using ArkTypes as our single source of truth for our data and deriving database schemas from them. This becomes very nice because ArkType's data model is close to an enriched version of TypeScript's own data model. So it's like having your TypeScript types introspectable and transformable at runtime.

That's neat, thanks!

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

#40

ArkType is a really interesting library that has a difficult time marketing itself. More than being a schema validator, it brings TS types into the runtime, so you can programmatically work with types as data with (near?) full fidelity. 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 w…

I recently went down this same rabbit hole for backend and stumbled on Typia[0] and Nestia[1] from the same developer. The DX with this is fantastic , especially when combined with Kysely[2] because now it's pure TypeScript end-to-end (no runtime schema artifacts and validations get AOT inlined). I was so shocked by how good this is that I ended up writing up a small deck (haven't had time to write this into a doc ye…

Thanks for sharing the deck! I had no idea Typia existed and it looks absolutely amazing. I guess I'll be trying it out this weekend or next :)
Post reply on HN