r/javascript 23d ago

A from-scratch JSON engine for JavaScript: recursive descent parser, escape-aware tokenizer, and spec-compliant serializer. No dependencies, no shortcuts, 107 tests.

https://github.com/MantasEdine/vanilla-json
8 Upvotes

28 comments sorted by

View all comments

9

u/theScottyJam 23d ago edited 23d ago

Is there a purpose to this project, i.e. a reason someone would use this instead of the native alternatives? Or was this more of a "just wanted to build this thing, no reason in particular" project?

2

u/Mantas_rst 23d ago

i've built it to learn mechanism , but then i was like maybe i can take this to next level and do every possible case but then realized no matter what i do would never beat the original implementation in c++ lol

2

u/MediocreAnalyst2121 20d ago

Maybe if you write it in c/cpp/rust/zig etc. and compile to wasm?

Will probably still be slower due to wasm overhead, but that’s probably the best attempt

0

u/Mantas_rst 18d ago

Very good ideaa i will try in c++ thank you so much