io_embed.wasm is the Io VM built as a WebAssembly component that other programs call. A host written in Python, Rust, Go, JavaScript or C# loads it with a component runtime; another component can import it. Either way the caller gets a typed interface: evaluate code, send messages to Io objects, read and set slots, get values and errors back.
The interface is wit/io.wit, package iolanguage:io@0.1.0. This is a first version: it is new and relatively untested, and the interface may change before 1.0.
Releases from 2026.11.28 on attach a prebuilt io_embed.wasm and io.wit on the releases page.
eval: func(code: string) -> result<value, error>;
lobby: func() -> object;
resource object {
perform: func(name: string, args: list<arg>) -> result<value, error>;
get-slot: func(name: string) -> value;
set-slot: func(name: string, v: arg) -> result<_, error>;
is-same: func(other: borrow<object>) -> bool;
}make embed # build/bin/io_embed.wasm (needs wasi-sdk)
make check-embed # a guest component calls it; needs wasmtime and wac
make check-embed-python # a Python host calls it; needs `pip install wasmtime`make check-embed builds a second component from test/guest.c, which imports the interface, joins the two with wac plug, and runs the result under wasmtime. Put wac on your PATH or at deps/wac/wac.
With a recent wasmtime (the --invoke form needs version 33 or later):
wasmtime run --invoke 'eval("list(1, 2, 3) map(x, x * x) sum")' build/bin/io_embed.wasm
# ok(number(14))
wasmtime run --invoke 'eval("1 foo")' build/bin/io_embed.wasm
# err({message: "Number does not respond to 'foo'", stack: "..."})The command line can only show plain values. Anything that returns an object handle needs a real host.
python/iolang.py is a small wrapper over the wasmtime package, and python/example.py uses it:
from iolang import Io
io = Io("io_embed.wasm")
io.eval("1 + 1") # 2.0
io.eval('Dog := Object clone do(name ::= nil; speak := method(name .. " says woof"))')
dog = io.eval("Dog clone") # a handle to an Io object
dog.perform("setName", "Rex")
dog.perform("speak") # 'Rex says woof'
io.lobby.set("pet", dog)
io.eval("pet name") # 'Rex'A handle is released when Python collects the IoObject, or at once with drop().
Import the interface in your world and compose with io_embed.wasm:
world my-app {
import iolanguage:io/vm@0.1.0;
}wac plug my-app.wasm --plug io_embed.wasm -o app.wasmtest/guest.c is a complete example in C, with bindings generated by wit-bindgen c.
Plain data is copied; everything else crosses as a handle.
| Io | Comes out as | Note |
|---|---|---|
| nil, true, false | nil, boolean | |
| Number | number (f64) | |
| Sequence holding text | text | Must be valid Unicode. Non-ASCII strings are transcoded to UTF-8. |
| Sequence holding other bytes | bytes | |
| BigInt | big-int | Decimal digits |
| Vector | numbers | Item type plus little-endian bytes. A Vector of 64-bit integers comes as a handle. |
| anything else | obj | Lists, Maps, blocks and methods included |
| an exception | the error of the result | Message and Io backtrace |
Going in, text becomes what a string literal is in Io (an immutable Sequence), bytes a mutable byte Sequence, numbers a Vector, and obj the object the handle refers to.
at, size, atPut, keys and so on with perform.big-int that is not a decimal integer, or numbers whose length is not a multiple of the item size, is an error before any message is sent or slot set.get-slot does not activate. A method comes back as a handle. Use perform to call it.eval and perform return when the code has finished, including any wait. Coroutines left running in the background make progress only during later calls.System exit ends the VM, not the host. The call that exits returns an error saying so, and so does every later call on that instance. Make a new instance to carry on.println writes to whatever the host connects there, and it is flushed before each call returns, so it stays in order with the host's own output.The component lives in embed/ in the repository: the interface, its implementation over the VM, the generated C bindings, the test guest and the Python wrapper. Release builds attach io_embed.wasm and io.wit.