Chapter 11 · 24 July – 17 September

Raku that travels

An interpreter that works in its developer's shell is the easy part. v4.0.0 was named, a month before any of its code existed, "Raku that travels". It set three goals: installing modules without Rakudo or zef, compiled binaries that carry everything they need or refuse to build, and Raku as a library other languages can call.

16.0 → 5.7 msto use XML, once parsed modules were cached
2.7 msa 278 KB JSON document through the native extension ABI, against ~440 ms in pure Raku
6host languages calling one C API: C++, Go, JavaScript, Python, Rust, Wolfram
The turnBefore v4.0.0, a module that could not be embedded in a compiled binary was skipped silently. The binary still built, and needed the disk at run time. Now every compile mode reports what it embedded and what it could not, and why. --standalone turns any such skip into a build failure.

Modules

The plan said to serve resources from memory. That was wrong: is native(%?RESOURCES<libraries/x>) hands its value to dlopen, which needs a path on a real filesystem. A distribution now writes its resources to one temporary directory on first use, and it is removed at exit. A binary that never reads a resource never creates one, and say "Hello" compiles byte-identically.

Raku as a library

The extension ABI turned out to be the harder half of an embedding API, so the two share one vocabulary of values rather than growing two. v3.1.0 (11 August) exported the C API, and the bindings followed: Python, C++, JavaScript on bun, Go and Rust on 12 August, then Wolfram on 24 August. Anton Antonov published the Wolfram one as a paclet, RakuppLink.

The reason anyone outside the project would care is grammars. "Embed Raku in Python" is abstract. "Use Raku grammars from Python" is something the host language has nothing like: a regex library gives you one pattern, not a composable grammar with named rules, inheritance and longest-token dispatch. The grammar stays a .raku file, and each host's class is generated from it. One corpus runs from every host in CI, and the outputs must match byte for byte.

More places to run