Live data from Hacker News

We rewrote our Rust WASM parser in TypeScript and it got faster

openui.com

141–150 of 239 posts

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#141
post #44

Earlier quoted context omitted.

In my experience Rust typically makes it a little bit harder to write the most efficient algo actually.

Would you be willing to give an example of this?

Mutating tree structures tends to be a fiddle (especially if you want parent pointers).

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#142
post #105
post #55

Not directly related to the post but what does OpenUI do? I'm finding it interesting but hard to understand. Is it an intermediate layer that makes LLMs generate better UI?

Its the library that bridges the gap between LLMs and live UI. Best example would be to imagine you want to build interactive charts within your AI agent (like Claude) The most obvious approach would be to let LLMs generate code and render it but that introduces problems like safety, UI consistency and speed. OpenUI solves those problems and provides a safe, consistent and token optimized runtime for the LLMs to rend…

Is it kinda similar to the new GenUI SDK for Flutter in that sense?

https://docs.flutter.dev/ai/genui

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#143

Earlier quoted context omitted.

My experience is the exact opposite. This was particularly true for one of the projects I've worked with in the past, where Python was chosen as the main language for a monitoring service. In short, it proved itself to be a disaster: just the Python process collecting and parsing the metrics of all programs consumed 30-40% of the processing power of the lower end boxes. In the end, the project went ahead for a while…

> but in the end it was deemed a waste of time when the whole project was terminated. The main lesson of the story. Just pick Python and move fast, kids. It doesn’t matter how fast your software is if nobody uses it.

You can use Go and get the best of both worlds.

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#146
post #74

Yeah if you're serializing and deserializing data across the JS-WASM boundary (or actually between web workers in general whether they're WASM or not) the data marshaling costs can add up. There is a way of sharing memory across the boundary though without any marshaling: TypedArrays and SharedArrayBuffers. TypedArrays let you transfer ownership of the underlying memory from one worker (or the main thread) to another…

So the actual processing is faster in rust/c/c++ but the marshaling costs are so big so ts is faster in this case? No vlue how something like swc does this but there it's way faster then babel.

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#148
This is why, when a programming language already has tooling for compilers, being it ahead of time, or dynamic, it pays off to first go around validating algorithms and data structures before a full rewrite.

Additionally even after those options are exhausted, only a key parts might need a rewrite, not the whole thing.

However, I wonder how many care about actually learning about algorithms, data structures and mechanical sympathy in the age of Electron apps.

It feels quite often that a rewrite is chosen, because knowing how to actually apply those skills is the CS stuff many think isn't worthwhile learning about.

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#149
post #148

This is why, when a programming language already has tooling for compilers, being it ahead of time, or dynamic, it pays off to first go around validating algorithms and data structures before a full rewrite. Additionally even after those options are exhausted, only a key parts might need a rewrite, not the whole thing. However, I wonder how many care about actually learning about algorithms, data structures and mecha…

>However, I wonder how many care about actually learning about algorithms, data structures and mechanical sympathy in the age of Electron apps.

Never mind the age of Electron apps, even fewer care about those in the age of agents.

Re: We rewrote our Rust WASM parser in TypeScript and it got faster

#150

The real win here isn't TS over Rust, it's the O(N²) -> O(N) streaming fix via statement-level caching. That's a 3.3x improvement on its own, independent of language choice. The WASM boundary elimination is 2-4x, but the algorithmic fix is what actually matters for user-perceived latency during streaming. Title undersells the more interesting engineering imo.

> The real win here isn't TS over Rust Kinda is. We came up with abstractions to help reason about what really matters. The more you need to deal with auxillary stuff (allocations, lifetimes), more likely you will miss the big issue.

The opposite: the more you rely on abstractions the more you miss the lower level optimization opportunities and loose understanding of algorithms and hardware.
Post reply on HN