We rewrote our Rust WASM Parser in TypeScript – and it got 3x Faster

openui.com
March 20, 2026
7 min read
🔥🔥🔥🔥🔥
62/100
Summary
OpenUI is rewriting its openui-lang parser from Rust to TypeScript to improve latency in converting a custom DSL emitted by an LLM into a React component tree. The original Rust-based parser utilized a six-stage pipeline but was found to be optimizing the wrong aspects for performance.
Key Takeaways
- The openui-lang parser was initially built in Rust and compiled to WASM, but the performance bottleneck was found to be the overhead of crossing the WASM boundary, not the Rust code itself.
- An attempt to optimize by skipping JSON serialization and returning a JS object directly resulted in a 30% decrease in performance due to the need for multiple conversions between Rust and JS data structures.
- The parser pipeline was successfully ported to TypeScript, achieving significant speed improvements with a 2.2x to 4.6x increase in parsing speed compared to the original WASM implementation.
- The original streaming architecture of the parser had an inefficiency that caused it to re-parse the entire string from scratch for every LLM chunk, leading to an O(N²) complexity in processing.
Coverage & discussions
Hacker News · openui.com
Community discussions
Community Sentiment
Positives
- The algorithmic improvement from O(N²) to O(N) through statement-level caching significantly enhances user-perceived latency, showcasing the importance of optimization beyond language choice.
- Rewriting the code allowed for the application of better practices and rectification of previous design flaws, emphasizing that thoughtful engineering can yield substantial performance gains.




