This tutorial is a continuation of the earlier Introduction to WebAssembly Text
If you are not familiar with WebAssembly Text (WAT), then please read the above introductory tutorial first because from this point on, I will assume that you are at least able to read and understand a WebAssembly Text program.
In the tutorials that follow, we will take a detailed look at how to implement an application in WebAssembly Text that plots the Mandelbrot and Julia Sets
But Why Not Just Write the Solution in Rust?
I did here!
But here’s the thing…
When I wrote the above solution in Rust, I enjoyed all the advantages of using a language with much richer programming constructs and a compiler that turns out almost bullet-proof code. However, when I used
wasm-pack to transform the Rust executable into a
.wasm module, the resulting file was 74Kb in size.
This is certainly not large, but it was much larger than I expected given the simplicity of the task being performed.
So as a matter of both curiosity and education, I set about re-implementing this program in WebAssembly Text (WAT) to see just how small I could get it.
The results are encouraging because the hand-crafted
.wasm file is now about 150 times smaller - just 493 bytes…