A tiny WebAssembly compiler, that also runs in a browser (Golang)

how to golang webassembly

The author wanted to learn how to make my own programming language for a really long time, but I could not find the road in the hard theory behind compilers, parsers, ASTs etc… I found the tutorials hard and my attention was not lasting for more than 5 minutes before completely shut down the project.

Some days ago, though, something changed.
I’m currently in love with WebAssembly and had this absurd idea of developing a programming language that compiles to WebAssembly.

I didn’t know how WebAssembly internals worked so it was the perfect stage to learn something new and make a cool project.

Sold!

What is WebAssembly about

Started doing some research and I found no tutorials except two amazing articles, one was about how to build a compile for a custom programming language that compiles to WebAssembly (exactly what I was looking for), and the other was a series of articles on how to build a Web assembly compiler (exactly what I was looking for, again!)

But here come the problems: the first was written in Typescript and the second in Rust.

How to do WebAssembly with Golang

I wanted to practice Go and I don’t know anything about Rust.

So long story short I studied the theory behind those two amazing articles, WebAssembly specification etc… and I started writing a compiler in Go (i love Go).

I’ve found no articles about writing WebAssembly compilers with Go, so I decided to document the building of Luna so future Gophers that will have my same idea won’t have to struggle as much as I did to find resources.