Compile Rust to WebAssembly and run it in the browser: a particle simulation whose physics run in Rust while the page just draws it. It is visual, shareable, and a practical look at Rust beyond the terminal.
In this episode:
Set up wasm-pack and wasm-bindgen
Export a simulation type from Rust to JavaScript
Compile to WebAssembly and load it from an HTML page
Draw the particles on a canvas, with Rust doing the physics
Resources:
Lesson code: https://github.com/willvelida/learn-r...
The Rust and WebAssembly book: https://rustwasm.github.io/docs/book/
The wasm-bindgen guide: https://rustwasm.github.io/wasm-bindgen/
More ways to learn Rust: https://www.rust-lang.org/learn/
#Rust #RustLang #WebAssembly