TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ArkType: Ergonomic TS validator 100x faster than Zod

192 pointsby nathan_phoenixabout 2 months ago

12 comments

webdevladderabout 2 months ago
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.<p>I&#x27;ve been evaluating schema libraries for a better-than-Zod source of truth, and ArkType is where I&#x27;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!<p>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&#x27;s a real cost that isn&#x27;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.<p>[1] <a href="https:&#x2F;&#x2F;v4.zod.dev&#x2F;v4" rel="nofollow">https:&#x2F;&#x2F;v4.zod.dev&#x2F;v4</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;arktypeio&#x2F;arktype&#x2F;issues&#x2F;810">https:&#x2F;&#x2F;github.com&#x2F;arktypeio&#x2F;arktype&#x2F;issues&#x2F;810</a>
评论 #43668804 未加载
评论 #43667024 未加载
评论 #43667645 未加载
评论 #43666883 未加载
Aeolunabout 2 months ago
ArkType looks anything but ergonomic to me. Typescript in strings? Double level type encoding?<p>It’s a miracle it can be 100x faster than Zod, but speed was never my issue with zod to begin with.
评论 #43671079 未加载
评论 #43673367 未加载
评论 #43672075 未加载
alganetabout 2 months ago
In validation, it&#x27;s never about speed. Is how you relate the schema tree to the error reporting tree. If you didn&#x27;t already, you will figure that out eventually.<p>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.<p>(source: 15 years intermittently maintaining a similar project).<p>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&#x27;t make it work in today&#x27;s software culture.
评论 #43670181 未加载
评论 #43670260 未加载
brapabout 2 months ago
Really conflicted with TS. On one hand it’s so impressive that a type system can do these sort of tricks. On the other hand if we had type introspection at runtime we wouldn’t need any of this.
评论 #43673409 未加载
Chyzwarabout 2 months ago
V4 of zod landed recently and it promises better perf <a href="https:&#x2F;&#x2F;v4.zod.dev&#x2F;v4" rel="nofollow">https:&#x2F;&#x2F;v4.zod.dev&#x2F;v4</a>
评论 #43667658 未加载
评论 #43666919 未加载
madeofpalkabout 2 months ago
Since recent typescript features have made it more possible, I’m less interested in runtime validation, and really only keen in build-type schema validation.<p>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.
评论 #43667186 未加载
评论 #43667117 未加载
评论 #43666942 未加载
评论 #43667457 未加载
chrisweeklyabout 2 months ago
With many TS features making their way into JS, I&#x27;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&#x2F; vanilla CSS].
评论 #43668810 未加载
domoritzabout 2 months ago
I like the idea of having types at runtime for parsing etc and generating validators in various languages. What stopped me from going there so far is that I already have TypeScript types provided for the various libraries I use. How good are the tools for importing TypeScript types into ArkType&#x2F;Zod and working with types in various representations in parallel?
评论 #43669723 未加载
t1amatabout 2 months ago
This looks interesting, however Zod has become a standard of sorts and a lot of libraries I use expect, for example, a JSON schema defined as a Zod schema. I would need some sort of adapter to a Zod schema to make this work for me.
cendyneabout 2 months ago
I&#x27;d be very interested in how to replicate parsing like this. Slow typescript inference has stalled my own exploration into things like this.
cugulabout 2 months ago
Is this at all related to Huawei&#x27;s ArkTS?<p><a href="https:&#x2F;&#x2F;developer.huawei.com&#x2F;consumer&#x2F;en&#x2F;doc&#x2F;harmonyos-guides-V14&#x2F;arkts-overview-V14" rel="nofollow">https:&#x2F;&#x2F;developer.huawei.com&#x2F;consumer&#x2F;en&#x2F;doc&#x2F;harmonyos-guide...</a>
评论 #43667697 未加载
tomaskafkaabout 2 months ago
TS: &quot;We have added types to javascript, everything is now strongly typed, and the compiler will pester you to no end until it&#x27;s happy with the types.&quot;<p>Me: &quot;Awesome, so I get an object from an API, it will be trivial to check at runtime if it&#x27;s of a given type. Or to have a debug mode that checks each function&#x27;s inputs to match the declared types. Otherwise the types would be just an empty charade. Right?&quot;<p>TS: &quot;What?&quot;<p>Me: &quot;What?&quot;<p>Realizing this was a true facepalm moment for me. No one ever thought of adding a debug TS mode where it would turn<p>function myFunc(a: string, b: number) {}<p>into<p>function myFunc(a: string, b: number) { assert(typeof a === &quot;string&quot;) assert(typeof b === &quot;number&quot;) }<p>to catch all the &quot;somebody fetched a wrong type from the backend&quot; or &quot;someone did some stupid ((a as any) as B) once to silence the compiler and now you can&#x27;t trust any type assertion about your codebase&quot; problems. Nada.
评论 #43673531 未加载