Stream: beginners

Topic: wasm


view this post on Zulip Brian Carroll (Aug 10 2021 at 23:01):

Hey just seeing this discussion on Wasm. In my Elm-in-Wasm project I originally built a back end that went directly to Wasm. But later I decided to go through C to make it easier to debug, and I could have kernel code in the C too, etc. Anyway I have a good understanding of how the instruction set works and that kind of thing, if that can be of use to people.

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:04):

Regarding .wasm and .wat formats, there's a WebAssembly Binary Toolkit that has some useful tools including translating back and forth between the two.

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:04):

There's also an optimizer there

view this post on Zulip Folkert de Vries (Aug 10 2021 at 23:08):

are there rust bindings for that? I thought wasm was pretty rust-centered but maybe not?

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:08):

The Wasm module is a data structure that I think more or less resembles an executable file like ELF or EXE. It has a data section and code sections and some tables and that kind of thing. Best resource I found for this was the spec itself, although that was a couple of years ago, maybe there's better stuff now. But this page shows you the module structure: https://webassembly.github.io/spec/core/syntax/modules.html

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:09):

No I definitely wouldn't say Wasm is Rust-centred! If anything maybe the other way around

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:09):

Rust does have good support for it

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:10):

But a lot of the actual Wasm development is more geared towards C and C++. And if you're using LLVM anyway then that has a Wasm back end so that would be the way to do it. Zig has a Wasm back end.

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:14):

I didn't use Rust for my project, only C. I did a tiny amount with Rust and Wasm like 2 or 3 years ago but can't remember now.

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:15):

I did create a Haskell type definition to represent the Wasm module though

view this post on Zulip Folkert de Vries (Aug 10 2021 at 23:15):

well sure we can go to wasm via llvm, but llvm is very slow

view this post on Zulip Folkert de Vries (Aug 10 2021 at 23:15):

which is why we're also working on direct assembly backends

view this post on Zulip Folkert de Vries (Aug 10 2021 at 23:16):

and would similarly ultimately like to emit wasm directly, for development purposes (a release/optimized build would still probably go via LLVM)

view this post on Zulip Brian Carroll (Aug 10 2021 at 23:16):

Right, I see

view this post on Zulip Richard Feldman (Aug 11 2021 at 01:39):

(moved this to its own topic!)

view this post on Zulip Richard Feldman (Aug 11 2021 at 01:40):

thanks for the wasm tips, Brian! :smiley:

view this post on Zulip Brian Carroll (Aug 11 2021 at 08:09):

Sure!
Looks like there are indeed Rust bindings for WABT, and it has struct definitions for a Wasm module etc. https://docs.rs/wabt/0.10.0/wabt/

view this post on Zulip Ally Jr Salim (Mar 30 2025 at 00:51):

Hey all! Getting started with roc and having trouble with compiling to wasm. Is there a simple (relatively recent) example of this? Is there a dedicated wasm platform?

I have found repos that are 2 years old, using zig, but I think the wasm story is much better now. Any examples / references would be appreciated!

Thanks

view this post on Zulip Brendan Hansknecht (Mar 30 2025 at 04:46):

I think most wasm platforms have been bespoke made for single apps. I don't think we have any flexible platforms. That said, we may have more recent examples. Oh, I guess, wasm4 is technically slightly flexible and wasm, but it isn't hooked into the browser directly. It is for a game engine.

view this post on Zulip Vladimir Zotov (Mar 30 2025 at 13:03):

There is an example of compilation to wasm (frontend stuff though)
https://github.com/lukewilliamboswell/roc-experiment-js-dom/blob/a0bf524d1d80ff8a36128611aa4de21c6d465bf7/run-web.sh#L15


Last updated: Jul 05 2025 at 12:14 UTC