WebAssembly Without Boilerplate



  • You want to learn WebAssembly (WASM) for coding web apps in [replace by your favorite language] instead of Javascript (because you h*te it!) and are not interested by the WebAssembly Text Format (WAT) : THIS EBOOK IS NOT FOR YOU !
    Indeed, there’re already many great tutorials about the amazing Emscripten project - the main door to discover WASM - in order to enter new realms of web development without javascript and capitalizing on existing code bases written in C/C++/Rust/[your language].
    Else you know javascript but not very well (use it just for jQuery plugins) : THIS EBOOK IS VERY PROBABLY NOT FOR YOU !

    Else you love modern frontend technologies and practices, and use them to develop web apps offering to your users experiences similar to native ones :
    snappy UI;
    damn fast loading time;
    offline mode;
    nearly no waiting time or UI freezing during information processing.

    Concretely, you’re familiar with the actions below to reach these goals :
    writing modern CSS / SVG to manage as much animations as possible and hence offload the javascript thread;
    using tiny yet powerful frameworks (ex: Preat, Redux, StencilJs, Svelte…);
    harnessing the Cache and Service Worker APIs (look for Progressive Web Apps) for offline applications;
    following good javascript practices :
    avoiding DOM accesses (relatively slow) when not absolutely necessary;
    using async patterns (Promises, generators) properly;
    not declaring new local variables in frequently called functions to avoid too much triggering of the garbage collector (=> temporary UI freezes);
    using native ES6 methods when your application target modern browsers;
    using Web Workers - to create additional threads - if some tasks can be executed in parallel;
    using WebGL to speed up drawings, or heavy operations (scientific libraries, artificial intelligence...).

    Still, your application has some bottlenecks. You’ve heard about the WebAssembly revolution, but the situation is not severe enough to rewrite the whole app from scratch in C++ or Rust - that you don’t know. Indeed, your bundle size is not very big, and instead the problem lies in a dozen of slow functions. Moreover, you want to experiment with the WASM technology without learning lots of tools. Above all, you want clear and succinct explanations but less dry than the official documentation. THIS BOOK IS PROBABLY FOR YOU! Indeed, each chapter show practical examples, that you can test in a few seconds by copying and pasting them into your browser console. Also, code samples are littered with detailed comments! For prerequisites, please check Appendix A.0.

    The book: https://docs.google.com/document/d/1K8EjLSKl62s_M7ZkDfuOizdsamv2UKUwwQRF2DmIba0/edit#


Log in to reply
 

SUGGESTED TOPICS

A community for developers looking to put WebAssembly to use today. Come rock WebAssembly with us!