WASM is Magic

Uncategorized

A few weeks ago I stumbled upon wasm when I was

  1. Looking for Rust projects to contribute to
  2. Looking for a way to write smart contract that was not in javascript

I came upon wasm for both of these things. So what is WASM? WASM is web assembly. It is a binary format for web application.   You can write an application in Rust, or C, or any language that compiles into web assembly and then load it into a web page. The benefit is near native performance (and not having to use Javascript).   There are also some security benefits to the way that web assembly memory is allocated – the execution stack is separated from the WASM stack. Here is a whole medium piece  someone wrote on JS and memory if you are interested.

I found it very magical writing something in rust and then publishing it as a node package and calling functions in another js function.

There are two resources I looked at for web assembly. The web assembly book https://rustwasm.github.io/book and https://rustwasm.github.io/book/game-of-life/implementing.html. I recommend the second one because it has a really interesting example of canvas integration with WASM. There is also a podcast on this week in rust about WASM.   AND just because WASM was written for the web, and has ‘web’ in the name does not mean it could not be used for other things. It could be like a better type of virtual machine (think JVM) or something. Some other good links are the awesome rust and wasm page and wasm-bindgen examples.  I also heard about an open frameworks-ish library in WASM from Max D.

It also made me think about the way JS communicates to Non JS. So JS and WASM, or JS and elm (ports). I am not sure why this is interesting, but there is something about this sort of interop that I find worth thinking about it.

I still have some more work to do on my personal Rust WASM project, and am going to work with Marko on a Rust WASM version of his breakout speed analysis comparison. I was going to put a link to the heroku deploy – but because of the rust module this is not trivial. I think I need to write a heroku build pack or publish the package to npm. But here is a screen cap – its in the browser !

This is unrelated to WASM, but J has a great blog post about editing our git history. This is super helpful since I sometimes get lazy on personal projects and commit with unhelpful messages. My main git trick is bfg, when I want to remove something that I should not have committed…. It happens.

Leave a Reply