What is Recoil?
Recoil is a low-level, statically-typed language that pairs Rebol's expressive, bracket-and-word syntax with compile-time memory safety. It transpiles to small, dependency-free C you can read, audit, and link with any toolchain.
A static borrow checker enforces ownership and move/copy semantics, catching use-after-free and double-free at compile time — without a garbage collector or runtime. That makes Recoil a fit for systems programming, embedding, tiny binaries, and clean FFI to existing C libraries.
A taste of Recoil
Bindings are implicitly typed — the compiler infers a value's type from the right-hand side. Functions return their last expression. Reach for make only when you need a specific type or a typed container.
Hello, world
print "Hello, Recoil!"
Functions and inferred types
add: func [a [i32!] b [i32!] return: [i32!]] [
a + b ; the last expression is the result
]
sum: add 10 20 ; type inferred from the call → i32!
print sum ; 30
Ownership, checked at compile time
greeting: make string! "Hello"
echo: greeting ; ownership moves to `echo`
print echo ; ok
print greeting ; compile error: 'greeting' used after move
Structs, vectors, and paths
point!: make struct! [x: i32! y: i32!]
p: make point! [x: 10 y: 20]
print p/x ; 10
nums: make [#mutable vector! [i32! 3]] []
nums/0: 42
print nums/0 ; 42
Call a C function directly
math: foreign <stdlib.h> [
abs: "abs" [i32! return: i32!]
]
x: math/abs -7
print x ; 7
Two things most systems languages don't have
Recoil ships pattern matching and state machines as first-class, compiled language constructs — fully type- and ownership-checked, lowered to plain C. No regex engine, no parser-generator step, no runtime interpreter.
PARSE — a compiled grammar dialect
Describe grammars and string/series matching declaratively. parse is a built-in, not a library call: rules compile straight to C.
print parse "abcd" ["ab" "cd"]
print parse "cd" ["ab" | "cd"]
chs: make bitset! charset ":/#?"
print parse "abc?" [thru chs]
FSM & FST — first-class state machines
Declare finite state machines and streaming transducers as types. Transitions, guards, and events are checked at compile time and emit C.
TrafficLight!: make fsm! [
events: [go [] slow [] stop []]
red [go => green]
green [slow => yellow]
yellow [stop => red]
]
light: make [#mutable TrafficLight!] TrafficLight!/red
send light go []
Key features
Memory safety without GC
A static borrow checker tracks ownership and move/copy at compile time — no use-after-free, no double-free, no collector.
Implicit static typing
Types are inferred from the right-hand side, so most code stays terse while every value still has a concrete compile-time type.
Readable C output
Transpiles to small, dependency-free C you can inspect and link with GCC/Clang. Constant folding and dead-code elimination built in.
Declarative FFI
Bind C libraries with a foreign block — headers, link flags, opaque pointers, and structs map cleanly across the boundary.
Closures & chaining
First-class function pointers and closures with explicit #capture, plus refinement-style method chaining.
Embeddable & tiny
No runtime to drag along. Build shared/static libraries, target ESP32 via ESP-IDF, or embed the f00 scripting VM.
How Recoil compares
| Feature | Recoil | Rust | Zig | Go | Rebol |
|---|---|---|---|---|---|
| Memory safety | Ownership | Ownership | Allocator | GC | GC |
| Static typing | Yes (inferred) | Yes | Yes | Yes | No |
| Compiles to C | Yes | No | Yes | No | No |
| Garbage collector | No | No | No | Yes | Yes |
| Borrow checker | Yes | Yes | No | No | No |
| Built-in PARSE | Yes | No | No | No | Yes |
| First-class state machines | Yes | No | No | No | No |
| FFI to C | Yes | Yes | Yes | Yes | Yes |
Coming from a dynamic language? The ownership model is intentionally simpler than Rust's, and the syntax stays close to Rebol/Red. Start with the Language Guide or browse Recoil by Example.
Where to go next
Getting Started →
Install Rebol 3 and a C compiler, then build and run your first program.
Language Guide →
Syntax, datatypes, control flow, functions, ownership, and error handling — basics to advanced.
Reference →
Operators, constructors, built-in actions, datatype actions, and diagnostics.
FFI & Systems →
Foreign functions, C structs, the unsafe namespace, ports, and networking.
f00 & Embedded →
The f00 scripting VM and building for ESP32 with ESP-IDF.
Ports →
Files, layered TCP/TLS/HTTP networking, and the server reactor.
Examples →
A guided tour of the language through small, complete programs.
Internals →
The compiler pipeline, AST/IR shapes, and how to inspect each stage.