ReScript Schema - The fastest parser in the entire JavaScript ecosystem with a focus on small bundle size and top-notch DX.
Why did you not hear a...
For further actions, you may consider blocking this person and/or reporting abuse
Nice work! Definitely will consider it next time I need a parser or a validator.
By the way, since you're familiar with Typia, have you by any chance seen a recent post by Typia's author about its performance with the Bun runtime being 20 times slower?
Would you perhaps have any comments on that? I'm also interested in how ReScript Schema performs with different runtimes (Node, Deno, Bun, browser)
Interesting, this is a new one. Just read it and left a like dev.to/samchon/bun-is-up-to-20x-sl...
Node.js, Deno and Browser are fine; the only problem is with Bun, which you can see in the community benchmark moltar.github.io/typescript-runtim...
I can see many comments in the article where people claim that it's a Typia specific problem, but Typia is a codegen library, and it doesn't do anything special in runtime. This means if you write a function like
(input) => "string" === typeof input
by hand and run it multiple times, it'll execute multiple times slower in Bun than in any other runtime.Hi Dmitry, nice article. In your last code example showing the under the hood code, on the 3rd line it says e7, where does the capital I come from or is that a typo?
Hm, this looks like a copy-paste bug from Google Docs where I initially written the article. It should be a lower case i. As for
e
it comes from the function context and used for safe embedding to eval code.I didn't even notice it stripped the brackets and parenthesis from my comment.
e[7](I)
what about comparison with typebox? It's also much faster than zod.
This is actually very good, and it's very mature. I actually had a misunderstanding about it being a worse version of Typia, but after double-checking the docs, I was really impressed by it.
In the benchmark, you can indeed see that it's fast moltar.github.io/typescript-runtim...
But there are some trade-offs that are solved in ReScript Schema:
So, at the moment of writing the article I think ReScript Schema is a better library if you use it for Web, but for server-side TypeBox is more mature and provides more flexibility and features. Although there are still some features of ReScript Schema you might want to use, which are not a part of TypeBox π
ReScript Schema v10 is coming, which will improve the flexibility similar to TypeBox while boosting DX even more, exceeding Zod and ArkType levels π
Ok, I decided to double-check the package size table from their docs and it actually happened that the package size is not big bundlephobia.com/package/@sinclair...
Another thing to compare is the much more readable error messages by default in ReScript Schema.
So why even use this if you can just use Zod or Valibot, bypassing any or all of that
eval
magic you did just for a few extra kilobytes?Eval actually makes the size bigger π
There are some unique features you can't find in any other library together:
If you don't need it, then use Zod or Valibot. Both of them are good libraries I like.
Hmm very interesting article. Though when i read eval it raised some concerns. Nonetheless good job.
It's indeed good to be aware of this because if you build for serverless or some widget that is embedded as a CDN to someone else website (CSP) there might be problems. But as I said, this is ~1% of use cases.
Also, ArkType uses eval, and according to Colin's words, he plans to add Eval mode to Zod v4.
Ideally, there should be a fallback mode to be able to work without Eval when it's not supported. I actually recently got an idea of how to implement it without reducing the quality of the library. But it'll probably take several months for me to implement.
Very cool, and thanks for the heads up about eval. It's a shame we can't use this in browser extensions because eval is not allowed in MV3 :-(.
Awesome !