A PoC of using WebAssemply as a Hot-Reloadable Code logic at Runtime without restarting the Host Process.
for a simple demo see this tweet
First make sure you have both Rust and NodeJS (also NPM) installed.
- Clone
$ git clone https://github.com/shekohex/rust-wasm-hotreload
- Build
$ npm install
$ npm run asbuild:optimized
$ cargo build
- Run
In one terminal, start build and watch for changes to our AssemplyScript File.
$ npm run watch
in another terminal simply run
$ cargo run
Now, just change the logic in the assembly/index.ts
file and watch the magic happen :).
This Project uses Rust and AssemblyScript to address these use cases:
- Scripting (by extending your program with other functionality by using WASM files).
- GameDev (again, it would be useful to add some game logic like (NPCs, Quests, ...etc) as WASM module for easy changes and fast development)
- User-Land Extentions.
- Your Case?
- Why use AssemplyScript rather than Rust for WASM?
Well, let's be honest here... rustc
compilation-time would kill the whole idea about Fast Hot Reloading™, and while AssemblyScript compiles so fast, it emits smaller code than rustc
would and yet it has almost the same performance, and that's why it's a better option for writing code that compiles to WASM.
Want to join us? take a look at some of these issues:
Licensed under MIT license.Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.