DEV Community

Cover image for Create Dev's offline page with Rust and WebAssembly ๐Ÿฆ„๐Ÿ’กโœจ

Create Dev's offline page with Rust and WebAssembly ๐Ÿฆ„๐Ÿ’กโœจ

Sendil Kumar on July 03, 2019

Dev's offline page is fun. Can we do that with Rust and WebAssembly? The answer is yes. Let us do it. First, we will create a simple Rust and W...
Collapse
 
aspittel profile image
Ali Spittel

This is awesome! I'm trying to learn WASM and having my own code translated to it is super helpful. Thank you!!!!!!

Collapse
 
sendilkumarn profile image
Sendil Kumar

So glad it helped ๐Ÿ™‚. Thanks ๐Ÿ‘

Collapse
 
sendilkumarn profile image
Sendil Kumar

WASM is ASM go for it...

Collapse
 
philnash profile image
Phil Nash

It is really cool to learn WASM by recreating existing web experiences in a different language and compiling. This is a great tutorial for that!

Is this a good idea for WASM in general though? The web_sys crate looks useful, but are you just jumping back and forth across the JavaScript/WASM boundary in order to achieve this, negating any performance benefits of WASM itself?

Collapse
 
sendilkumarn profile image
Sendil Kumar

That is an awesome question.Boundary crossing is an important factor for any WASM app.

Performance wise it will be slightly slower every crossing here adds few nano seconds overhead. but browsers like Firefox is optimised well enough. You will have a problem only when you transfer huge chunk of data.

General advise will be use WASM where you need to have computation heavy operation and minimize boundary crossing

Collapse
 
suhanyujie profile image
Samuel Su

It seems that I should add "DomTokenList" to the feature list

Collapse
 
ben profile image
Ben Halpern

Soooo cool!

Collapse
 
sendilkumarn profile image
Sendil Kumar

Thanks ๐Ÿ™‚

Collapse
 
andrewbrown profile image
Andrew Brown ๐Ÿ‡จ๐Ÿ‡ฆ

I was going to try and do this with Ruby and WebAssembly but gave up. So hard to get Ruby to WebAssembly.

Collapse
 
sendilkumarn profile image
Sendil Kumar

Oh, that is interesting! What is the most painful part of it?

Collapse
 
andrewbrown profile image
Andrew Brown ๐Ÿ‡จ๐Ÿ‡ฆ

You have to use MRuby which is an embedded ruby that has serious limitations. The ruby-wasm gem appears to need to compile Mruby to Emscripten. Then it wants Java for some reason. When compiling obscure errors occur.

So lots of moving parts, no time to debug.

Collapse
 
suhanyujie profile image
Samuel Su • Edited

Oh,does it has any image for the final page....

Collapse
 
suhanyujie profile image
Samuel Su

I saw that-- dev.to/offline
Thanks for sharing~

Collapse
 
suhanyujie profile image
Samuel Su • Edited

Emmm,the article is great! And i have translated it into Chinese. dev.to/suhanyujie/rust-webassembly...
If you don't like this,i'll delete it follow your mind...
Thank u

Collapse
 
sendilkumarn profile image
Sendil Kumar

Wow thats awesome ๐ŸŽ‰๐Ÿ‘

Collapse
 
lampewebdev profile image
Michael "lampe" Lazarski

Amazing post!

I want to deep dive into wasm myself and this gives me to push to do it :)

Collapse
 
sendilkumarn profile image
Sendil Kumar

Yay! Go for it. WASM is AWSM.