Bindings
Raku inside your own program. Run Raku code, call Raku subs with your values, and parse text with Raku grammars — the results come back as your language's own types.
| Python | Ready. pip install rakulang — macOS, Linux and Windows, the engine inside the package. |
| Wolfram Language | Available as the RakuppLink paclet in Wolfram's Paclet Repository. |
| JavaScript | Preview, for Bun. Built from the repository. |
| Go | Preview, with cgo. Built from the repository. |
| Rust | Preview, a crate built from the repository. |
| C++ | Preview, two headers that ship with the engine. |
| iOS and Android | The engine compiled into an app and called through the C API from Swift, Kotlin or Flutter. |
Python #
pip install rakulang
Python 3.9 or later, on macOS, Linux or Windows. Nothing to compile and nothing else to install: the package carries its own Raku engine.
import rakulang
raku = rakulang.interpreter()
raku.eval('say "Hello from Raku!"')
print(raku.eval("(1..10).sum"))
print(raku.eval("2 ** 100"))
print(raku.eval("<apple banana cherry>.map(*.uc)"))
Hello from Raku!
55
1267650600228229401496703205376
['APPLE', 'BANANA', 'CHERRY']
eval returns ordinary Python values — numbers, strings, lists, dicts —
and integers of any size arrive exactly. Everything you declare stays in the
interpreter, so a sub defined in one call can be used in the next, or called
straight from Python with raku.call("name", …).
Parsing with a grammar #
import rakulang
source = """
grammar Shopping {
rule TOP { <item>+ }
rule item { <name> '=' <qty> }
token name { \\w+ }
token qty { \\d+ }
}
class ShoppingActions {
method item($/) { make $<qty>.Int }
method TOP($/) { make $<item>.map(*.made).sum }
}
"""
shopping = rakulang.Grammar.from_source(source, name="Shopping",
actions="ShoppingActions")
m = shopping.parse("milk=2 bread = 1\neggs=12")
for item in m["item"]:
print(item["name"].str(), item["qty"].int())
print("total:", m.made)
milk 2
bread 1
eggs 12
total: 15
The guide,
rakulang — Raku from Python,
goes on to your own operators, grammars kept in their own .raku file,
errors, and how every type converts.
Wolfram Language #
Raku from Mathematica or the Wolfram Engine 13.3+, published in Wolfram's own Paclet Repository as RakuppLink by Anton Antonov:
PacletInstall["AntonAntonov/RakuppLink"]
Needs["AntonAntonov`RakuppLink`"]
RakuppEval["[*] 1..20"] (* 2432902008176640000 *)
It needs rakupp installed, whose library it
loads: a release archive, the install script and Homebrew on macOS all carry
it, and a build of your own needs it built as below.
Version 1.0.3 or newer of the paclet is the one in which say shows
in a notebook. More on the Editors page and in
the binding's guide.
Previews: JavaScript, Go, Rust and C++ #
These four work and are tested on every push, but they are not published as
packages yet and their surface may still change. They load
librakupp, the engine as a shared library.
Every release archive
except OpenBSD's carries it: lib/librakupp.dylib on macOS,
lib/librakupp.so on Linux, bin/librakupp.dll on Windows.
With the archive's bin/ on PATH the bindings find it on their own;
otherwise set RAKUPP_LIB to the file. To build it from the
repository instead:
cmake -B build -DCMAKE_BUILD_TYPE=Release -DRAKUPP_BUILD_SHARED=ON
cmake --build build -j
If you already build rakupp for everyday work, keep that build/
static: the shared library compiles every runtime source a second time. Build
the library alone, in a directory of its own, and set RAKUPP_LIB to
the full path of the librakupp it makes, since the
rakupp on your PATH has none beside it:
cmake -B build-shared -DCMAKE_BUILD_TYPE=Release -DRAKUPP_BUILD_SHARED=ON
cmake --build build-shared -j --target rakupp_shared
| JavaScript | A single-file ES module over bun:ffi. Bun only: plain Node.js cannot run it. |
| Go | A single-file cgo package. Go 1.18+ and a C compiler. |
| Rust | A small crate: hand-declared extern "C" bindings and a build.rs that finds the library. |
| C++ | Header-only <rakupp/raku.hpp> and <rakupp/grammar.hpp>, linked against the library. |
Every guide has the same nine sections in the same order, so you can read one and skim the rest. The overview puts the six APIs side by side.
How it works #
- One engine, nothing re-implemented. Each binding is a thin layer over
librakupp's C API, so the Raku is exactly what plainrakuppruns. A test byte-compares the two to keep it that way. - The same program in every language. The
calcexample is written six times and prints the same seven lines in each,30!included. - Your own types. An
Intarrives as your integer, aHashas your dict or map; a Rakudiearrives as your language's own error. - Your own C or C++ program can embed the engine directly, through the same C API: see EMBEDDING.md.
- A phone app can too: the engine compiles into an iOS or Android app as native code — see Raku in a mobile app.