ReScript decoding libraries benchmark

I’m working on a new decoding library for ReScript, and decided to make a benchmark for other popular libraries to get the idea of the current state of the ecosystem.

The result highlight is:

For comparison there are some popular JS libraries:

You can take a look at the full graph at:
https://dzakh.github.io/rescript-runtime-type-benchmarks/

I haven’t done a benchmark for Js.Json.t, but if you’re interested in my opinion it should be slower than rescript-jzon if you want to have a result based API, and slower than bs-json if you want to have exception based API.

Also, I’ve taken a look at the code generated by decco, and had a thought that making it a little bit more dirty and unsafe, it might have a similar performance to ajv or even better. That’s the opposite to my library rescript-struct where I almost hit a performance maximum caused by library design.

If I missed some good decoding libraries, let me know, I’ll add them to the benchmark.

5 Likes

It would be interesting to add atd to the comparison.

1 Like

Can you send a link to a decoding library that can be used with it.

https://atd.readthedocs.io/en/latest/atdgen.html

Atdgen generates *.ml files that can be consumed from the rescript code. We evaluated this setup once and everything seemed to work, but due to overall complexity (opam, code generation, ml syntax) we decided to stick with decco.

I’ll take a look at it when I have more time. But PRs are always welcomed https://github.com/DZakh/rescript-runtime-type-benchmarks

To use atdgen in a ReScript project, follow the instructions in the runtime:

I’ve taken ownership of the executable generator project but haven’t had time to rename it to a rescript name yet.

I use this in production and find it much better than decco, which I used to rely on but the overhead of a ppx on a large project is substantial. The atdgen runtime is based on bs-json, though, so it might only be as fast as that (but it’s much easier to develop with).

I’ll contribute atd to the benchmark if I get a chance, but I’m fairly busy at the moment.

3 Likes

Could you add https://github.com/gcanti/io-ts to your benchmark?

I forked https://github.com/moltar/typescript-runtime-type-benchmarks, so it’s already there

1 Like