Saturday, November 16, 2019

WASM: Web Assembly, AssemblyScript book

Web Assembly (WASM) comes in two formats:
  • portable binary format, with file extension .wasm
  • text format, with file extension .wat
For most cases .wat is still quite low level, and there is option to use an "AssemblyScript",
an extended strongly typed subset of TypeScript, and compile that to .wasm directly.
The file extension of AssemblyScript is still .ts, same as TypeScript, and that may confuse IDEs.

Converting WebAssembly text format to wasm - WebAssembly | MDN

Introduction - The AssemblyScript Book

assemblyscript/examples at master · AssemblyScript/assemblyscript @GitHub

The simplest way to get started with WebAssembly - Benedek Gagyi - Medium

.WASM is also a compile target for many languages now.

  • Rust is quite popular choice since it produces safe, compact and efficient .wasm code, and has good tools for WebAssembly toolchain.
  • GoLang compiler provides .wasm compilation target also, while files are larger singe it includes runtime with its own GC
  • C-based languages that are using LLVM (C, C++, Swift) have compilation target for .wasm
  • .NET Core (C#) can be compiled to .wasm, by leveraging Mono compiler that is C/LLVM based. The runtime is included and relatively large, while tools are quite good. "Blazor" is leveraging ASP.NET C# templates for web apps.

Useful code examples:

JeremyLikness (Jeremy Likness) / Repositories (WASM) @GitHub

JeremyLikness/wasm-trees: An example of memory management/passing buffers between WebAssembly and JavaScript

JeremyLikness/PlasmaWasmGo: Implementation of Plasma effect in WebAssembly using Go

JeremyLikness/PlasmaWasmRust: Implementation of plasma effect using WebAssembly compiled from Rust.

JeremyLikness/blazor-wasm: Blazor and WebAssembly examples (part of a Blazor presentation)

Presentations and tutorials:

WebAssembly: Your Browser is the new OS - Jeremy Likness - YouTube

THAT Conference '19: WebAssembly: The Swiss Army Knife of Browser Apps | Pluralsight

WebAssembly for Web Developers (Google I/O ’19) - YouTube

Lin Clark: A Cartoon Intro to WebAssembly | JSConf EU 2017 - YouTube


WebAssembly/binaryen: Compiler infrastructure and toolchain library for WebAssembly
Compiler infrastructure and toolchain library for WebAssembly

has a simple 
C API in a single header, and can also be used from JavaScript. It accepts input in WebAssembly-like form but also accepts a general control flow graph for compilers that prefer that.

No comments: