R

Rust and WebAssembly

rustwasm.github.io · Company blog · on HN since 2018

The Rust and WebAssembly working group site hosts the book, announcements, and docs for wasm-bindgen, web-sys, and Gloo.

What HN saysHN links it for its guides, such as the code size reduction reference, though commenters worry the group is no longer maintained.
56HN people shared it
46linked it in comments
13stories submitted
471story points
11 months agolast shared
2018people per year2026

Most-shared posts

  1. 1
    Rust and WebAssembly
    9 people · 5 points · first shared 2018 · discussion on HN
  2. 2
    Book
    6 people · first shared 2020
  3. 3
    Dom
    5 people · first shared 2018
  4. 4
    Wasm bindgen
    4 people · first shared 2019
  5. 5
    Rust and WebAssembly Book
    3 people · 2 points · first shared 2021 · discussion on HN
  6. 6
    Multithreading Rust and Wasm
    2 people · 237 points · first shared 2018 · 45 comments on HN
  7. 7
    Announcing the web-sys crate
    2 people · 15 points · first shared 2018 · discussion on HN
  8. 8
    Let’s Build Gloo Together – Rust and WebAssembly
    2 people · 2 points · first shared 2019 · discussion on HN
  9. 9
    Wasm pack
    2 people · first shared 2020
  10. 10
    Code size
    2 people · first shared 2022
  11. 11
    Index
    2 people · first shared 2018
  12. 12
    Web sys
    2 people · first shared 2021
  13. 13
    Dom
    2 people · first shared 2022
  14. 14
    Hello world
    2 people · first shared 2022
  15. 15
    Our Vision for Rust and WebAssembly
    1 people · 196 points · first shared 2018 · 40 comments on HN

What HN people wrote when they linked it

starwatch · 2025-09-16
After seeing warnings about rustwasm not being maintained [1], I'm glad that wasm-bindgen is still actively supported [2]. That said, it's concerning that many previously recommended practices (e.g. like relying on wasm-pack) are now in question [3]. This makes it harder for devs to adopt Rust for building WASM apps. [1]: https://rustwasm.github.io/docs/book/ [2]: https://github.com/wasm-bindgen [3]: https://github.com/wasm-bindgen/wasm-bindgen/issues/4634
josephg · 2023-11-15
Yeah. And hello world is (thankfully) much smaller now than it used to be. Bigger than you think if you use printf, which is a quite complex C function. But at a guess, 10kb or something including support files. There are some great guides and tooling around to help shrink wasm size. Eg for rust: https://rustwasm.github.io/docs/book/reference/code-size.html
jauntywundrkind · 2023-11-07
wasm-bindgen is writing it's own ABI, but still involves a ton of auto-generated JS stubs running for you in the background. it works great! you would never know it's there, but it has a serious performance hit versus actual host object bridging (what we're working towards) since it has to keep serializing things over MessageChannels. You can read some about the auto-generated shims here, https://rustwasm.github.io/docs/wasm-bindgen/contributing/design/impor… . And you can see that wasm-bindgen doesn't actually send objects into Rust, but instead has shims here: https://rustwasm.github.io/docs/wasm-bindgen/contributing/design/js-ob… Component Model is designed to eliminate the need for having this autogenerated rpc system & many of these shims, and let wasm itself actually hold references & invoke/use objects in a genuinely shared fashion.
grantjpowell · 2023-01-30
Love the article. In my mind I see the problem of dynamic linking in rust to have a bunch of overlap with the "I want this rust library to be exposed in my higher level GC'd language with minimal safety issues/tedious handmaintained bindings" problem. My hunch is that the lack of expressiveness of the C ABI is holding back both. the thing I'd love to see some sort of "higher level than the C ABI" come out. And something like `wasm-bindgen`[0] to exist for more languages. Here's a link to the rust "interopable_api" proposal! I don't understand all the implications, but it seems to be in the right direction https://github.com/rust-lang/rust/pull/105586 [0]https://rustwasm.github.io/docs/wasm-bindgen/
PudgePacket · 2022-01-09
There are a number of techniques available to shrink wasm size in rust, this is the best collection of them I'm aware of https://rustwasm.github.io/docs/book/reference/code-size.html. Please also consider Unity web used to be significantly worse and it took multiples of bevy's lifetime for it to get to where it is now :)
the_duke · 2020-12-31
Rust has the best tooling for wasm and is easiest to get started with, in my opinion. `rustup target add wasm32-unknown-unknown` `cargo build --target=wasm32-unknown-unknown` Is all you need to compile a Rust library to a `.wasm` file. (almost, you also need a setting in Cargo.toml: [lib] crate-type = ["cdylib", "rlib"] ) In the browser you can get access to DOM apis via web-sys. The documentation has quite a lot of examples and info: https://rustwasm.github.io/wasm-bindgen/web-sys/index.html wasm-pack (https://github.com/rustwasm/wasm-pack) makes building code for the browser easy.
_nhynes · 2019-06-02
> C without the standard library (called “libc”) is pretty rough If you don't want to pull in musl or a traditional libc, there's a more Wasm-y solution known as the Web Assembly System Interface (WASI) [0] that delegates the libc functionality to the runtime. A WASI Wasm module can be compiled using clang, as in the article. The only difference is to use the WASI sysroot [1]. > optimization LTO and -O3 are great! I've also found the Twiggy [2] tool useful for more "manual" optimization. [0] https://wasi.dev [1] https://github.com/CraneStation/wasi-sdk/releases [2] https://rustwasm.github.io/twiggy/
mattdeboard · 2018-11-27
Yeah buddy. https://servo.org/ Also there is already amazing work for Rust and WASM https://rustwasm.github.io/book/
willglynn · 2018-10-30
Rust has a pretty great WebAssembly story: https://rustwasm.github.io/book/ Learning Rust at the same time as Rust+WebAssembly might be a bit of a reach, though.
Twirrim · 2023-03-15
Almost every language has a simple walk through that goes step by step and explains what parts are, or gets you to the point of having your first working application. Here you go "here's how to set up your build platform".. and good luck? The content under that github repo doesn't explain anything. It's just a dump of code. Why are the various parts there, how does this interact with TeaVM, how does this interact with the web page and why? The documents are written assuming knowledge, and the code does nothing to actually explain what is going on, how things should be laid out or anything. There's no readme, and no comments other than the license blurb. How does someone with no familiarity with TeaVM at all, know how to even get started? I appreciate writing documentation sucks, but if you want your project to take off, it's not enough for it to be good on a technical level. You need to be hand holding through the entire initial process. One of the things that is consistent right throughout technology is that the best solution isn't the one that gets chosen. It's the one that has the lowest barrier of entry, and the best user experience. One of the things that catapulted Ruby from being some obscure language to immense popularity was the first Ruby on Rails tutorials that had you making a functional blog site, taking you from first line of code to functional site pretty quickly. Ruby wasn't that special or unique as a language, but suddenly this framework came…
zmw · 2018-10-23
I only spent about an hour on the rust + wasm app for fun, so I treated wasm-bindgen and wasm-pack as black boxes and didn't really try to understand the inner workings. You're probably right about serialization, but I'm not sure it has to copy huge buffers around. Look, the supported types in wasm-bindgen are somewhat restricted. The full list is here [1]. Other than "atomic" types like numbers and pointers (I assume the opaque types are treated as pointers too), the interesting one are str/String (basically &[u8] under the hood) and number slices. It's apparently not great if you have to copy these around, but since these are well-aligned, why can't you just pass the starting address and length? Again, I don't know enough about wasm or its current state to say if this is doable. Maybe it doesn't like "someone else's memory" at the moment. (By the way, wasm-bindgen allows you to access pub fields of structs from JS, but they have to be Copy. That is to say, the opaque types are not completely opaque, but I'm not sure if the pub field access is achieved through implicit getter methods or serialized in the first place.) Anyway, the frictions might be a big problem if you're doing React-style DOM re-renders all the time, but in my app, I'm only running the computation heavy and memory sensitive tasks in wasm, and communications are few and far between, making it a non-issue. [1] https://rustwasm.github.io/wasm-bindgen/reference/types.html
vinhnx · 2025-11-24
I find the RustWasm book has a section on profiling throughput and latency performance for Rust Wasm: https://rustwasm.github.io/book/reference/time-profiling.html. Hope it helps.
simon_void · 2025-09-18
I works very well, thank you for asking: https://rustwasm.github.io/book/
flohofwoe · 2025-09-17
> The idea of doing DOM manipulation in a language that is not Javascript ...is already possible, see for instance: https://rustwasm.github.io/docs/wasm-bindgen/examples/dom.html You don't need to write Javascript to access the DOM. Such bindings still call JS under the hood of course to access the DOM API, but that's an implementation detail which isn't really important for the library user.
WirelessGigabit · 2023-10-19
The inability to attach a debugger is a dealbreaker for me: https://rustwasm.github.io/docs/book/reference/debugging.html#using-a-… Web-Assembly not returning cleared memory is an issue, but not a dealbreaker: https://webassembly.github.io/spec/core/syntax/instructions.html#memor…
benatkin · 2023-07-02
Along the same lines, wasm-bindgen can generate the TypeScript types: https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-rust-e…
chrisco255 · 2023-05-03
Not a production example, but good "academic" examples are found in the Rust & WebAssembly Gitbook: https://rustwasm.github.io/docs/book/introduction.html
ly3xqhl8g9 · 2023-03-11
Sure, but the context is very important: you can use Rust to control the DOM from WASM [1] and then you can use Haskell to write a load balancer [2]. [1] https://rustwasm.github.io/wasm-bindgen/examples/dom.html [2] https://thewagner.net/blog/2019/01/30/load-balancer (off-topic: Rob Pike's Concurrency is not Parallelism https://www.youtube.com/watch?v=oV9rvDllKEg)
lucasyvas · 2022-11-07
The top Reddit example is tremendous. I'm passed being a Rust beginner, but I have a note to the Rust community: Your official examples are overcomplicated and bad and you should also feel a little bad. Stick to things like apple, orange, pear and you'll see much easier adoption than if you go with something like LendingIterator! Through the GAT process all I have seen is the same hyper-specific example used that confuses the hell out of people that just need the "Hello World" version. If you want, I will volunteer to be the test subject "dumb" Rust programmer to vet the quality of future examples. Tangentially related - here's a WASM example that goes from "Hello World" to Conway's Game of Life (I shit you not, that's actually how the tutorial progresses): https://rustwasm.github.io/docs/book/
pjmlp · 2022-07-15
Counter example of what? A graph representation of nodes based on JavaScript object model? Fine, https://rustwasm.github.io/docs/wasm-bindgen/examples/dom.html
cogman10 · 2022-07-14
Probably never an official one. That'd sort of defeat some of the point of WASM. What already exists is multiple bridge libraries to make porting stuff from JS -> WASM and back again easier. For example: https://rustwasm.github.io/wasm-bindgen/examples/dom.html
jsheard · 2022-07-13
If you're targeting browsers then the Rust WASM book goes over using wasm32-unknown-unknown with wasm_bindgen to auto-generate the JS glue https://rustwasm.github.io/docs/book/ If you're targeting some WASI-based platform then it's more straightforward, since no JS glue is needed. CF have a quick example https://blog.cloudflare.com/announcing-wasi-on-workers/
karpierz · 2022-07-04
I've been learning Rust for the past few weeks and have been enjoying it a lot. - The community is very helpful on Discord (https://discord.com/invite/rust-lang-community). - The package ecosystem (crates.io) makes it very easy to find and import things, and they're consistently documented. - There's a path to compiling on web via WebAssembly (https://rustwasm.github.io/wasm-pack/) In a few weeks of learning the language, I managed to put together this visualization: https://twitter.com/admiralakk/status/1542560489091350529 But realistically, either Go or Rust will be fine. You should pick the one you're more likely to stick with and learn, even when it gets tough. I've found the community aspect to be very helpful, because then at least I know I'm not the only idiot out there.
jka · 2022-05-22
Naive question: what's the advantage of this compared to using 'npm init wasm-app'[1], importing your Rust WASM module from JavaScript, and iterating from there? [1] - https://rustwasm.github.io/docs/book/game-of-life/hello-world.html#put…
meheleventyone · 2021-12-17
Rust has probably the most batteries included, with explanation, of most of the languages that compile to WASM right now. It has a lot of tooling that takes some of the underlying pain out of interfacing with JS. There's even an online guide for it: https://rustwasm.github.io/book/
yoru-sulfur · 2021-11-13
Nice work. Funny coincidence I was just going through https://rustwasm.github.io/docs/book/ today, so Rust, WebAssembly, and the Game of Life was already on my mind.
RReverser · 2021-07-21
Yeah Rust's wasm-bindgen has integration between Rust async-await and JavaScript promises which doesn't have same restrictions: https://rustwasm.github.io/wasm-bindgen/reference/js-promises-and-rust… However, Asyncify is useful in other scenarios - where you want to shim out an API that is normally synchronous in C / Rust land, with an async JS implementation. async-await, like any coroutine-based mechanism, requires changing every single function in the entire callstack to be async as well, which is usually not feasible in such scenarios (e.g. when shimming out some basic filesystem API). That's where Asyncify helps a lot.
smolder · 2021-01-16
I used wasm bindgen to make rust code callable from js. https://rustwasm.github.io/docs/wasm-bindgen/

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close