Is Rust/WASM based web-UI worthwhile for smaller projects?

I am definitely not a fronted dev, but I had to implement a small thing with a very simple web-based UI involving a websocket and table-based view being updated by it. Simple enough that even I can do it. :smiley:

I really dislike working with JS, even though I do know JS well enough, so I was considering using Rust for UI. However, to employ WASM, I would have to bring in whole set of tools, some framework to take care of DOM-WASM impedance mismatch (of which most seem rather immature), and at the end I would get something like 500KB large binary, to replace 400 lines of JS code. Did not seem worth it. Had my project require some large, complex UI that would require some large JS UI framework anyway, maybe it would be worth it.

It seems right now JS gets everything included with every browser, while Rust has to bring everything including memory allocator with every binary.

Am I mistaken somewhere here? Are there any thing that would make it better than I described? Are there any future developments that would make WASM more appealing for smaller scope projects?

You may want to look into other JS alternatives, such as Elm, ReScript, PureScript or even F#. There are (many) more out there, but these are the ones I'm at least somewhat familiar with.

I share your dislike of JS and chose Elm for a personal project of mine last year. I also wrote elm_rs which automates away a common painpoint when learning Elm, namely writing JSON encoders/decoders. I have not regretted it so far, but you may prefer one of the other ones.

1 Like

i recommend you the amazing Ui crate called egui

1 Like

Oh wow. That's really impressive.

But it does come in a 4MB wasm binary (which seems fair for the amount of wow it packs), which is exactly my worry.

That's the correct description of the state. WASM is good for pure computation, and could work as a "back-end" for web apps, but without direct DOM access it's only getting in the way of interacting with the browser.

For simple projects I'd stick with JS or TypeScript. Even "large" UI frameworks for JS are still relatively small and low-overhead compared to the same with WASM.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.