A tabular, pure-by-default functional & systems programming language built for massive parallelism, native isolated agents, symbolic tensor algebra, and deterministic zero-GC memory management.
Ridgun combines the declarative clarity of tabular functional programming with native systems performance. Its self-hosted compiler (ridgunc) and project manager/formatter (stable) are written 100% in pure Ridgun (src/main/ridgun/, zero Rust/C code or external compiler dependencies) and emit standalone, statically linked Linux ELF64 executables (x86_64 and ARM64 / Raspberry Pi) directly to disk with zero Garbage Collector pauses.
๐ The Ridgun Book โ Complete Guide in 8 Languages
Learn Ridgun from scratchโfrom your first tabular function to parallel DAGs, the Native Agent Model (agent, send ... to, receive from), symbolic tensors, and RMM1/RMM2 deterministic memory managementโin your preferred language:
Quick Start
Ridgun ships with two self-hosted toolsโridgunc (the single-file compiler & runner) and stable (the project manager, typechecker, test runner, and canonical tabular formatter)โconfigured via a pure Ridgun build.rg file (no YAML, JSON, or TOML):
# Type-check all project modules in src/main/ridgun/
./target/stable check
# Compile & run all test suites in src/test/ridgun/
./target/stable test
# Format all .rg source files into canonical tabular alignment
./target/stable format
# Build all project targets into target/ (or install into ~/.local/bin/)
./target/stable built
./target/stable built lib
./target/stable install
# Scaffold a new app or library project, list tasks/plugins, or sync dependencies
./target/stable new my_app
./target/stable new --lib my_lib
./target/stable tasks
./target/stable plugins
./target/stable deps
# Compile or run a single .rg file or library directly with ridgunc (x86_64 or ARM64 Raspberry Pi)
./target/ridgunc check my_program.rg
./target/ridgunc run my_program.rg
./target/ridgunc build my_program.rg -o my_program
./target/ridgunc build --lib my_lib.rg -o my_lib.rglib
./target/ridgunc build --so my_lib.rg -o libmy_lib.so
./target/ridgunc build --target arm64-linux my_program.rg -o my_program_arm64
Release Verification (minisign)
Official Ridgun release downloads (SHA256SUMS) are signed with minisign using the following Ed25519 public key:
RWQuKPmgklF+8SxAc6VK4RdRg/vw1/jBXvq5E0YcBN5QcFjezotHHWvq
Verify a downloaded release before unpacking:
minisign -Vm SHA256SUMS -P RWQuKPmgklF+8SxAc6VK4RdRg/vw1/jBXvq5E0YcBN5QcFjezotHHWvq
sha256sum -c SHA256SUMS
What Makes Ridgun Different?
- Code as a 2D Table (
=>,=,->): Type signatures act as column headers. Pattern-matching clauses align each argument beneath its type and align=beneath=>.stable format(and GNU Emacsridgun-mode) formats your code automatically. - Unified
=Block Grammar ((none),|,||) & Compact Nested Closers (|./||.):
- Every
=(in functions, operators, local bindingsx =, or guard branches) accepts sequential lines, conditional guard blocks (|), or parallel DAG blocks (||). - Guard branches can nest 3โ4+ levels deep to form rich decision trees, using the compact inline
|.closer (| otherwise = val |.) only when returning to an outer branch level below.
- Parallel DAG Blocks (
|| expr -> var), Multicore Combinators (||map,||filter), and the Native Agent Model (agent,send ... to,receive from):
- Parallel dataflow dependencies are declared directly with
|| expr -> var(nowherekeyword required). The static analyzer verifies cycle freedom at compile time and schedules independent branches in parallel. map,filter, andfoldexecute sequentially left-to-right, while||mapand||filterdistribute list elements across multicore worker threads using Ridgun's||parallel prefix.- Zero-boilerplate Native Agent Model & Smart Compile-Time Strategy Selection (
FR-COMP-009): Any standard function or operator (fn ::orop ::) can be wrapped into an isolated concurrent agent in one line (ag = agent (my fn)for stateless agents, orag = agent (step fn) init_statefor stateful/session agentsS M => SandS M => S R). Communicate via statically typedsend msg to ag(or multi-argumentsend a b to ag), blockingreceive from ag, non-blockingtry receive from ag(Some r | None), andstop ag(which deterministically frees the agent's isolated state viaRMM1/RMM2). At compile time,ridguncanalyzes each function's call depth and computational cost across||,||map,||filter, andagent, executing lightweight functions (StratInlineSequential) as zero-overhead green-thread steps and automatically dispatching heavy or deeply recursive functions (StratLazyStealableTask/StratKernelWorkerJob) across real OS kernel threads (SYS_clone).
- Immutable by Default (
x = ...) with Explicitmut(mut x = ...):
- Local bindings are immutable constants unless declared with
mut x = expr, preventing accidental rebinding in the same scope.
- Deterministic Memory Without a Garbage Collector (
RMM1,RMM2&with region):
- Policy
RMM1(Compiled Memory Management): Static last-use deallocation (rg_cmm_drop), zero-copy return moves (rg_cmm_move), and 1-cycle pointer-identity guards (ptr(a) != ptr(c)) for branching functions. - Policy
RMM2(Assignment & Cascaded Structure Counting): Incoming function arguments are untouched (+0/-0), local/container assignments add+1, returned locals are spared in transit, and non-returned locals cascade-1through child structures on scope exit. - Lexical Regions (
with region 64_KB do) & Timeouts (with timeout 250_ms): Enforce hard byte quotas and wall-clock execution deadlines on untrusted workloads and free entire arenas in $O(1)$.
- Natural-Language Spaces in
fn ::&op ::, Unified Tuple/Sequence Signatures (FR-COMP-008), Openexpand type, Polymorphism (A..Z), and Symbolic Tensors (@):
- Define multi-word functions and N-ary operators with natural spaces instead of underscores (
fn :: format err AppErr => String,op :: clamp Int between Int and Int => Int). - Argument sequences and tuples are unified (
FR-COMP-008): write clean space-separated tuple and return type signatures (=> Int Int [String String] String,[String String],(A B)) without comma clutter. - Share ADT constructor names across types (
Error,Var), use bare type names as variants (type Something = String | Int | MyStruct Float Int), extend types viaexpand type, and merge newfn ::clauses automatically before_catch-alls. - Single uppercase letters (
A..Z) act as zero-noise polymorphic type variables. - Native
Tensor[N, K]types check symbolic dimensions at compile time and support Einstein summation (A_ik @ B_kj) and Hadamard broadcasting (A_ij * B_j).
A Taste of Ridgun
-- 1. Tabular pattern matching, natural spaces & zero-noise polymorphism (A..Z)
head or [A] A => A
head or [] d = d
head or (x:_) _ = x
-- 2. Bare type-name variants, `expand type` & automatic `fn ::` clause merging
type Something = String | Int | MyStruct Float Int
fn :: describe something Something => String
describe something (String s) = "str:{s}"
describe something (Int n) = "int:{n}"
describe something (MyStruct f count) = "struct:{f}:{count}"
describe something _ = "other"
expand type Something = Bool
fn :: describe something Something => String
describe something (Bool b) = "bool:{b}"
-- 3. Natural-language mixfix operator with `=` + `|` guards
op :: clamp Int between Int and Int => Int
clamp x between lo and hi =
| x < lo = lo
| x > hi = hi
| otherwise = x
-- 4. Multi-level decision tree with compact inline `|.` closers
fn :: route request Int Int Bool Bool Int Int => Int
route request method role is_signed is_admin payload_kb rate_limited =
| method == 0 =
| payload_kb == 0 = 204
| otherwise = 200 |.
| method == 1 =
| not is_signed = 401
| otherwise =
| rate_limited > 0 =
| is_admin =
| payload_kb > 10000 = 413
| otherwise = 202 |.
| otherwise = 429 |.
| payload_kb > 1000 =
| role >= 2 and is_admin = 201
| otherwise = 413 |.
| otherwise = 201 |.
| otherwise = 405
-- 5. Parallel DAG block (`|| expr -> var`) without `where` + `||.` closer
fn :: quarterly balance Int => Int
quarterly balance base =
|| base * 100 -> gross_sales
|| base * 40 -> fixed_costs
|| gross_sales - fixed_costs -> gross_profit ||.
gross_profit * 80 / 100
-- 6. Conditional local variable (`x = | ...`) and explicit `mut` accumulator
fn :: compute total Bool Int => Int
compute total is_vip raw =
discount =
| is_vip and raw > 50 = 20
| otherwise = 0
mut total = raw - discount
total = total + 5
total
-- 7. Symbolic-dimension Tensor contraction (Einstein summation `@`)
fn :: linear layer Tensor[B, In] Tensor[In, Out] Tensor[B, Out] => Tensor[B, Out]
linear layer x weights bias = (x_bi @ weights_io) + bias
-- 8. Native Agent Model (`agent`, `send ... to`, `receive from`, `stop`)
fn :: add visit Int Int => Int
add visit acc n = acc + n
fn :: track visits Int => Int
track visits delta =
counter = agent (add visit) 10
send delta to counter
total = receive from counter
stop counter
total
Self-Hosted Architecture (src/main/ridgun/)
Ridgun Source (.rg) + build.rg
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ lexer.rg & parser.rg โ Tokenization, Mixfix Resolution, Unified `=` (`|`, `||`, `|.`, `||.`)
โโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ typecheck.rg โ Polymorphic `A..Z`, `mut` Immutability Check, Symbolic Tensor Dims
โโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ analyzer.rg โ Static `||` DAG Cycle Detection & Work-Stealing Strategy Inference
โโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโ
โ compiler.rg โ Call-Graph Tree-Shaking, TCO (`loop`), `RMM1` & `RMM2` Lowering
โโโโโโโฌโโโโโโโโโโโโโฌโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโ Bytecode (`.rgc`)
โ x86_64.rg โ (`vm.rg` Stack VM)
โ arm64.rg โ
โ elf64.rg โ
โโโโโโโฌโโโโโโ
โผ
Native ELF64 (`x86_64` / `ARM64`)
Project Layout
ridgun/
โโโ build.rg # Pure-Ridgun project manifest for `stable`
โโโ editors/
โ โโโ emacs/ridgun-mode.el # GNU Emacs major mode with tabular alignment
โโโ src/
โ โโโ main/ridgun/
โ โ โโโ lib/
โ โ โ โโโ ast.rg # Compiler & VM Algebraic Data Types
โ โ โ โโโ lexer.rg # Lexical scanner & byte-unit literals (_KB, _MB, _GB)
โ โ โ โโโ parser.rg # Recursive-descent parser & mixfix normalizer
โ โ โ โโโ typecheck.rg # Typechecker, A..Z unification & tensor shape checker
โ โ โ โโโ analyzer.rg # Static parallel DAG & strategy analyzer
โ โ โ โโโ compiler.rg # RMM1/RMM2 analyzer, native IR lowerer & .rgc compiler
โ โ โ โโโ elf64.rg # Direct Linux ELF64 executable binary emitter
โ โ โ โโโ x86_64.rg # Pure-Ridgun 2-pass x86_64 machine-code assembler & kernel
โ โ โ โโโ arm64.rg # Pure-Ridgun 2-pass ARM64 (AArch64 / Raspberry Pi) assembler
โ โ โ โโโ formatter.rg # Canonical tabular code formatter (`stable format`)
โ โ โ โโโ vm.rg # Meta-circular stack virtual machine
โ โ โโโ ridgunc/main.rg # Self-hosted `ridgunc` CLI entry point
โ โ โโโ stable/main.rg # Self-hosted `stable` project manager CLI entry point
โ โโโ test/ridgun/ # Self-hosted Ridgun test suites (`test_*.rg`)
โโโ docs/
โ โโโ book/ # The Ridgun Book in 7 languages (es, ca, gl, eu, en, pt, sv)
โ โโโ lang/spec.md # Formal language specification
โ โโโ etc/cmm_architecture.md# RMM1 & RMM2 memory management architecture
โ โโโ requirements/ # Functional requirements (FR-COMP-*, FR-TOOL-*, FR-VM-*)
โโโ target/ # Compiled self-hosted ELF64 binaries (`ridgunc`, `stable`)
Technical Documentation
| Document | Description |
|---|---|
Language Specification (docs/lang/spec.md) | Complete syntax, type system, unified = blocks, ` |
RMM Memory Architecture (docs/etc/cmm_architecture.md) | Detailed design of RMM1 (Linear & Conditional CMM) and RMM2 (Assignment & Cascaded Structure Counting) |
Low-Level Runtime Design (docs/etc/low_level_ridgun_runtime_design.md) | Architecture and instruction design for the 100% pure-Ridgun symbolic x86_64 and ARM64 runtime kernels |
FR-COMP-009 (docs/requirements/functional/compiler/) | Requirement specification for Ridgun's Native Agent Model (agent, send ... to, receive from, try receive from, stop) |
FR-COMP-008 (docs/requirements/functional/compiler/) | Requirement specification for unified space-separated tuple and sequence type signatures |
FR-COMP-004 (docs/requirements/functional/compiler/) | Requirement specification for 100% pure-Ridgun native ELF64 machine-code generation (x86_64 and ARM64 Raspberry Pi) without Rust or rustc |
FR-COMP-003 (docs/requirements/functional/compiler/) | Requirement specification for unified = grammar, ` |
FR-COMP-002 (docs/requirements/functional/compiler/) | Requirement specification for RMM1 and RMM2 deterministic memory management |
Roadmap & Active Tasks (docs/road-map/INDEX.md) | Current session state, completed milestones, and backlog |
License
Apache 2.0 โ see LICENSE.