Requirements
Recoil transpiles to C, so you need two things on your machine:
- A C compiler — GCC or Clang. The generated C is plain and portable.
- Rebol 3 — the compiler itself is written in Rebol. Use the actively maintained Oldes build of Rebol 3 (the
bulkvariant is the easiest to start with). Binaries exist for Linux, macOS, the BSDs, Haiku, and Windows.
The Rebol executable is usually called r3 (sometimes rebol3). All commands below use r3.
support/docker
in two flavours: Alpine (musl) and Debian-slim (glibc).
Get the source
git clone https://codeberg.org/rebolek/recoil.git
cd recoil
-s? Recoil runs with r3 -s, which disables Rebol's
security sandbox so the compiler can write generated C and invoke the C
toolchain. It is required for builds and tests.
Your first program
Create a file called hello.rcl:
; hello.rcl
print "Hello, Recoil!"
Compile and run it:
r3 -s recoil.r3 hello.rcl
./hello
The compiler emits a C file, invokes your C compiler, and produces a native binary next to the source. To see the generated C without building a binary, transpile only:
r3 -s recoil.r3 --transpile hello.rcl
Try it
A slightly bigger program
Bindings are implicitly typed and functions return their last expression:
; sum.rcl
add: func [a [i32!] b [i32!] return: [i32!]] [
a + b
]
total: add 2 40
print total ; 42
Read the Language Guide for the full syntax, or skim Recoil by Example for more complete programs.
Building libraries
Recoil can emit shared or static libraries with a generated C header. Mark
functions with #export (see Packages & Libraries), then:
# Shared library (name derived from the source file)
r3 -s recoil.r3 --lib mylib.rcl
# Shared library with a custom name
r3 -s recoil.r3 --lib mylib.rcl --name mylib
# Static library
r3 -s recoil.r3 --lib mylib.rcl --static
Note that --lib comes before the source file.
Running the test suite
The project uses its own test runner, RUT. Verify your setup:
# Run the whole suite
r3 -s rut.r3
# A specific test by title
r3 -s rut.r3 -t "Mandelbrot"
# A single test file
r3 -s rut.r3 -F parser.reb
# List available tests
r3 -s rut.r3 --list
Run RUT with r3 -s rut.r3 (not r3 rut.r3), and only one
build at a time — RUT enforces a single active runner via a lock.
Next steps
Language Guide →
Syntax, datatypes, ownership, control flow, functions, errors.
PARSE →
The compiled pattern-matching dialect.
State Machines →
First-class FSMs and streaming transducers.
FFI & Systems →
Bind C libraries and work with ports.