Getting Started with AssemblyScript

AssemblyScript, in my opinion, is probably the best entrypoint into writing WebAssembly for web developers. It’s a programming language with a familiar syntax, basically it’s a subset of TypeScript, i.e. JavaScript with type annotation. From a JavaScript developers point of view its pretty straightforward, from a Typescript developers point of view, you’ll notice that it’s missing certain conveniences. There’s basically no smart type inferencing so you’ll need to give everything a type. There are no union types and no any types so it’s a lot stricter.

None of this is much of a hardship however and this gets you past WebAssembly’s own arcane Lisp-ish, FORTH-ish language syntax (which I kind of dig TBH) and also give you access to more advanced types such as strings and records. The basic WebAssembly language only handles integers and floats.

Implementing a Javascript-like language implies a lot of other things. Number one of those is memory management, automatic garbage collection and function closures. None of this exist WebAssembly and was therefore needed to be built into AssemblyScript.

The end result however is really nice. While still at an early stage of development compared with more C and Rust-based solutions. I think we have a good system to explore the power of WebAssembly without too much sacrifice. The problem domain for AssemblyScript at this stage is still very small and restricted to computationally heavy things like crypto and image processing but it holds out the promise of being able to completely eliminate all native code dependencies. I think it’s a good time for web developers to really start paying attention to this.

For a good introduction to Web Assembly see https://www.sitepen.com/blog/getting-started-with-assemblyscript/

Leave a comment