Passing strings between TinyGo and JavaScript

After getting a “Hello, World!" WebAssembly application working I thought it would be fun to try and implement a toy programming language in the browser. However before I could even start thinking about parsers, abstract syntax trees and the like I had to be able to pass strings between my WebAssembly module and the surrounding JavaScript.

Turns out that is much trickier than I expected.

Saying 'Hello, World!' with TinyGo and WebAssembly

WebAssembly is something I’ve wanted to play with for quite a while now and I’ve finally got around to taking a look at it. In this post I describe how I managed to use TinyGo to compile a “Hello, World!” Go program into WebAssembly and execute it in the browser. So that I have something to refer back to I also describe setting up my development environment as a container using LXD.