Hello, WebAssembly
This tutorial walks through writing and running your first woua program step by step.
What you'll build
A program that prints a greeting to the terminal using the io library.
The program
(include io)
(defn main ()
(printf "hello %s!\n" (string "world")))
What's happening
(include io)pulls in the I/O library, which itself includeswasi_p1andstring.(defn main () ...)declares the entry point — woua exports_startpointing tomain.(string "world")allocates aStringstruct on the heap pointing to the static bytes for"world".(printf "hello %s!\n" ...)is a compile-time macro that scans the format string and emits the appropriate print calls.
Compile and run
wasmtime --dir . wouac/dist/wouac.wasm hello.woua -o hello.wat
wat2wasm hello.wat -o hello.wasm
wasmtime hello.wasm
# hello world!
Next steps
Continue with Variables and types to learn how to declare locals, work with integers, and define your own struct types.