Richard Bucker

Webassembly or Chicken?

Posted at — Jul 14, 2022

The formal description of WebAssembly can be found on it’s website. But for my purpose it’s an interpreter/executioner/VM that runs on the command line, as a service, and in the browser. Famous examples include “Castle Wolfenstein” and other ID software. I’m certain it’ll execute more but it does execute compiled c, go, and rust. It’ll also run javascript. From the doc it’s already included in FireFox, Chrome, Safari, Explorer; so it is available on all these platforms and so there is a cross platform virtual machine view of the world.

web assembly is a cross operating system virtual machine

“it’ll run javascript”… well not really. Javascript is an interpreted language and therefore would need a compiler to produce webassembly. Anyway that’s another rabbit hole I’mnot very interested in. However, to this point WASM does check a few boxes.

And then there is chicken. Chicken started as a DSL I designed as a subset of TCL. It was named tcldsl with roots from picol.go and picol.c but deicded to call it chicken because of the pets and cattle story… and my belief that chickens are better than cattle when you’re already a farmer.

The parser for chicken is only about 500 lines. Then I added some core functions similar to tcl and then I added more predicates as needed like sql, http, xlsx, dovnc and so on. The reason for chicken is that in my line of work capturing the design, configuration as code, and literate programming are all more important than raw bare metal performance. If for some reason golang were no longer in fashion the interpreter could be rewritten in rust, c, or any other language.

write once; execute anywhere golang does

WebAssembly is an interesting choice. There are clearly some benefits… but in my disaster first plan I’ll assume that I’d rather build another interpreter from scratch rather than having to replace all the business logic.