TLDR Tech / Dev
Engineering High-Performance Parsers with Data-Oriented Design
Yuku is a JavaScript/TypeScript parser in Zig that runs 3–10x faster than npm alternatives. Its speed comes not from the grammar, but from representing the AST as flat arrays of u32 indices instead of a pointer tree. That one decision cascades into everything else: strings become source offsets, variable-length children live in a shared array, token metadata is packed into tag bits, Unicode tables are deduplicated to stay cache-resident, and serialization to JavaScript is just a memcpy since the pointerless tree is already position-independent bytes.
Read the full story