Skip to content
Tech News
← Back to articles

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

read original get TypeScript Programming Book → more articles
Why This Matters

Rewriting the openui-lang parser from Rust to TypeScript resulted in a threefold increase in speed, primarily by reducing the overhead associated with WebAssembly calls. This highlights the importance of optimizing not just core logic but also the communication costs between JavaScript and WASM, which can significantly impact performance in latency-sensitive applications. The findings suggest that for certain use cases, leveraging TypeScript may outperform Rust in WASM environments due to lower overheads.

Key Takeaways

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

Thesys Engineering Team · Fri Mar 13 2026

We built the openui-lang parser in Rust and compiled it to WASM. The logic was sound: Rust is fast, WASM gives you near-native speed in the browser, and our parser is a reasonably complex multi-stage pipeline. Why wouldn't you want that in Rust?

Turns out we were optimising the wrong thing.

The openui-lang parser converts a custom DSL emitted by an LLM into a React component tree. It runs on every streaming chunk — so latency matters a lot. The pipeline has six stages:

autocloser → lexer → splitter → parser → resolver → mapper → ParseResult

Autocloser : makes partial (mid-stream) text syntactically valid by appending minimal closing brackets/quotes

: makes partial (mid-stream) text syntactically valid by appending minimal closing brackets/quotes Lexer : single-pass character scanner, emits typed tokens

: single-pass character scanner, emits typed tokens Splitter : cuts the token stream into id = expression statements

: cuts the token stream into statements Parser : recursive-descent expression parser, builds an AST

... continue reading