.nib guide std nib 0.3.1-pre

The nib guide

How a nib program is put together, and what the compiler does with it — the part of the language that is not a function in the standard library.

The standard library reference says what each function, type and effector does. This guide covers the rest: how a program is laid out and run, and the machinery underneath — the walker that runs a program as written, the native and WebAssembly backends that compile it, the parallel kernels the walker uses on its own, effectors that live in another process, and the journal that makes a run replayable.

The walkthrough builds one small program from a single function up to a served page, and the internals chapters each take one piece of the toolchain apart: what it does, the flags that drive it, what it guarantees, and what it refuses. Every nib example on these pages was compiled and run by the compiler version in the header when the page was built; the output under it is what that run printed. Command lines with measured numbers were run by hand, and say where and when.

Walkthrough

A program, from one function to a server
The shape of every nib program — modules, interfaces, effectors and the wire that joins them — built up one step at a time.

Internals

The toolchain at a glance
What happens between a .nib file and an answer — the stages every program passes, and the three ways it can then run.
Compiling to native code
nibc build --target native turns a wire into an executable through LLVM — the value model, the fibre host that serves sockets, and how it stays byte-for-byte equal to the walker.
Compiling to WebAssembly
The wasm32 module and the wasm32-wasip2 component — the same lowering as native, a 32-bit memory, and a host the program cannot see past.
Parallel kernels
How the walker runs an ordinary Vec.map or Vec.fold on several cores — with no parallel syntax, and an answer bit-identical to the serial one.
Effectors in another process
System.Remote binds an interface to a daemon over a socket — nib's foreign-function interface, typed by the interface, versioned by its declaration, journalled like any effect.
The journal, replay and handoff
Every answer the world gives a nib program crosses one seam, so a run can be written down, replayed without the world, and cut in one process to be finished in another.