Read more about Mozilla’s plan here.
What is wasm-bindgen?
It’s worth reading this from the Mozilla blog to see the logic behind wasm-bidgen and how it’s going to work:
“Today the WebAssembly specification only defines four types: two integer types and two floating-point types. Most of the time, however, JS and Rust developers are working with much richer types! For example, JS developers often interact with
documentto add or modify HTML nodes, while Rust developers work with types like
Resultfor error handling, and almost all programmers work with strings.
Being limited only to the types that WebAssembly provides today would be far too restrictive, and this is where
wasm-bindgencomes into the picture. The goal of
wasm-bindgenis to provide a bridge between the types of JS and Rust. It allows JS to call a Rust API with a string, or a Rust function to catch a JS exception.
This is exciting as it is a valuable step in expanding the capabilities of Rust. But the thinking behind wasm-bindgen will also help to further drive the adoption of web assembly. While the focus is, of course, on Rust at the moment, there’s a possibility that wasm-bindgen could eventually be used with other languages, such as C and C++. This might take some time, owever.
Download wasm-bindgen from GitHub.