unrust icon indicating copy to clipboard operation
unrust copied to clipboard

Investigate replacing stdweb with wasm-bindgen ?

Open jice-nospam opened this issue 6 years ago • 5 comments

This is an exploratory issue. wasm-bindgen is making great progress and might be much faster than stdweb for passing data between Rust and js. That might be very interesting, especially for opengl buffers. https://hacks.mozilla.org/2018/04/javascript-to-rust-and-back-again-a-wasm-bindgen-tale/

Maybe we could start investigating wasm-bindgen on some lower module, like uni_pad or uni_snd

jice-nospam avatar Apr 12 '18 14:04 jice-nospam

Indeed, i had this idea before, but we should figure out how following items works :

  • What is the output of these lower module ? A wasm file + JS file (using wasm-bindgen) ? And how do we "link" these deliverables when the main engine ?
  • If cargo do support linking wasm file directly (i don't know), how can we run the game without cargo web ?

Basically, i do not have the big picture about how JS and rust cooperate. Do you have any idea about it?

edwin0cheng avatar Apr 12 '18 14:04 edwin0cheng

No idea so far but i'll start playing with it. In my idea, we should still have a single wasm, only replacing internal stdweb glue with wasm-bindgen. I don't now if this impacts cargo-web though.

jice-nospam avatar Apr 12 '18 14:04 jice-nospam

On the other hand, if custom task is landed, we can write a custom task to build all the js glue code , html and other assets we need to run the game. But even this is not landed, we can still make a cargo sub-command to do so.

edwin0cheng avatar Apr 12 '18 14:04 edwin0cheng

If we have a sub-command, we can go a lot of crazy stuff like preprocessing asset to an bundle, convert file format, etc. I start to think it is a very good idea. :)

edwin0cheng avatar Apr 12 '18 14:04 edwin0cheng

A cargo unrust sub command ? This looks sexy !

jice-nospam avatar Apr 12 '18 16:04 jice-nospam