shekohex / rust-wasm-hotreload

PoC Using WASM Modules as Hot-Reloading Logic from Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust + WASM = 🔥 Hot-Reload 🔥

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

Try it

First make sure you have both Rust and NodeJS (also NPM) installed.

  1. Clone
$ git clone https://github.com/shekohex/rust-wasm-hotreload
  1. Build
$ npm install
$ npm run asbuild:optimized
$ cargo build
  1. 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 :).

Use Cases

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?

FAQ

  1. 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.

Contributing

Want to join us? take a look at some of these issues:

License

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.

About

PoC Using WASM Modules as Hot-Reloading Logic from Rust.

License:MIT License


Languages

Language:Rust 98.0%Language:TypeScript 2.0%