Languages like C, Go, and Rust were built for humans typing text at a keyboard. When an AI agent writes Rust or C today, it outputs thousands of characters of text, and the compiler (rustc or LLVM) spends seconds parsing that text, checking memory rules, and searching for loop optimizations.
Rul (.rl) removes the human text layer. Instead of writing text source files, an AI agent emits a compact list of fixed 16-byte (128-bit) binary instructions. Every 16-byte instruction carries three pieces of information up front:
- The operation (such as add, compare, filter, or reduce).
- How to run it on the CPU (a 1-byte schedule hint selecting single-core SIMD or multi-core execution).
- A memory safety tag (a version number and bounds index proving the memory access is valid).
Because the AI provides the CPU schedule and safety tags inside each instruction, the Rul compiler does not need to guess or run slow optimization passes:
- Fast safety checks: Rul verifies memory ownership, array bounds, the termination policy, and I/O permissions in a single forward pass (~5.8 nanoseconds per instruction, or under 60 microseconds for 10,000 instructions).
- Microsecond native compilation: Rul compiles verified
.rlprograms directly into standalone Linuxx86_64executables (628 to 1,037 bytes) in ~6.4 microseconds, without LLVM or an external linker. - Easy for humans to inspect: Humans never need to write
.rlby hand, but can inspect any program at any time usingrul decompile(readable text view) orrul trace(which prints the exactmin,max,sum, andNaNcount at every step).
Install the standalone rul binary and create, verify, compile, run, and trace a .rl program in 30 seconds (no Cargo.toml or rustc required to run .rl projects):
# 1. Install the standalone rul toolchain
curl -fsSL https://raw.githubusercontent.com/rul-lang/rul/main/install.sh | sh
# 2. Create a sample Rul project (rul.toml, src/main.rls, data/arena_0.bin)
rul new my-ai-pipeline && cd my-ai-pipeline
# 3. Verify in microseconds, compile a standalone ~880-byte Linux ELF64 binary, and run
rul check
rul run
# 4. Inspect the exact min/max/sum/NaN output at every step (#0..#6)
rul traceReadable Assembly View (src/main.rls — 7 instructions = 208 bytes in binary .rl):
cap 0x0
arena 0 len=4096 lane=f64x8 mut=false align=64 ver=1
node $n0 = ArenaInput f64x8 fg=1 pol=simd proof=0 tok=read(0,1) a=0 b=0
node $n1 = ConstF64 f64x1 fg=1 pol=simd proof=0 tok=pure const=100.0
node $n2 = CmpGt maskx8 fg=1 pol=simd proof=0 tok=pure a=$n0 b=$n1
node $n3 = Mul f64x8 fg=1 pol=simd proof=0 tok=pure a=$n0 b=$n0
node $n4 = SelectZero f64x8 fg=1 pol=simd proof=0 tok=pure a=$n2 b=$n3
node $n5 = ReduceSum f64x1 fg=1 pol=simd proof=0 tok=pure a=$n4 b=0
node $n6 = AssertContract f64x1 fg=1 pol=simd proof=0 tok=pure a=$n5 b=0
output $n6
Output of rul trace (Step-by-Step Inspector):
=== RUL (.rl) WHITE-BOX EXECUTION TRACE (7 SSA Nodes) ===
NODE OPCODE LIVE KIND LEN MIN MAX SUM/TRUES NAN/INF SAMPLE[0..4]
#0 ArenaInput yes ColumnF64 4096 0.5000 249.5000 504608.0000 0 [0.500, 1.500, 2.500, 3.500]
#1 ConstF64 yes Scalar 1 100.0000 100.0000 100.0000 0 [100.000]
#2 CmpGt yes ColumnMask 4096 0.0000 1.0000 2400.0000 0 [0.000, 0.000, 0.000, 0.000]
#3 Mul yes ColumnF64 4096 0.2500 62250.2500 83627904.0000 0 [0.250, 2.250, 6.250, 12.250]
#4 SelectZero yes ColumnF64 4096 0.0000 62250.2500 77999800.0000 0 [0.000, 0.000, 0.000, 0.000]
#5 ReduceSum yes Scalar 1 77999800.0000 77999800.0000 77999800.0000 0 [77999800.000]
#6 AssertContract yes Scalar 1 77999800.0000 77999800.0000 77999800.0000 0 [77999800.000]
Traditional languages force a trade-off between memory safety, runtime speed, and compile time because the compiler has to infer what the human programmer meant. Rul avoids that trade-off through four simple mechanisms:
- No Text Parsing (
0%Syntax Errors):- AI agents emit 16-byte binary instructions directly (or assemble flat
.rlslistings in ~8.8 microseconds). - A 7-step pipeline over 10 million numbers is
192 bytesin.rland compiles into a standalone817-byteLinuxELF64binary.
- AI agents emit 16-byte binary instructions directly (or assemble flat
- Versioned Memory Buffers Instead of a Slow Borrow Checker:
- Every memory buffer (
Arena) starts at version1. - Multiple instructions can read version
1at the same time (ReadLease). - If an instruction modifies a mutable buffer in place (
AffineConsume), it consumes version1and advances the buffer to version2. Any later instruction that still tries to read or write version1is rejected immediately. - This gives AI-generated code Rust-grade protection against use-after-free and aliasing bugs in a single linear scan (
5.78 ns/instruction).
- Every memory buffer (
- Compile-Time Bounds Proofs and Hardware Capability Bits:
- Operations on matching array lengths need zero runtime bounds checks. Sub-slices (
ArenaSlice) and indirect lookups (Gather) reference a 16-byteProofEntrytable checked at load time. - The 64-byte file header includes a
CapabilityMaskbitfield. When set to0x0(CAP_NONE), instructions that perform external I/O are rejected before the program can run.
- Operations on matching array lengths need zero runtime bounds checks. Sub-slices (
- Cache-Friendly Columnar Memory and Single-Byte Schedule Tuning:
- Data is stored in 64-byte-aligned columnar arrays (
Structure-of-Arrays) so CPU vector registers only load the fields they actually use. - Changing a single byte (
ScheduleHint) switches execution from single-core SIMD (pol=simd) to all CPU cores (pol=multicore) without rewriting the algorithm.
- Data is stored in 64-byte-aligned columnar arrays (
Workload: Filter elements > 1000.0, square matching values, and sum to a scalar.
| Implementation | Execution Mode | Median Latency | Effective Logical Bandwidth | Speedup vs. C 8-Acc (1-Core) | Speedup vs. Legacy AoS |
|---|---|---|---|---|---|
[A] Imperative AoS + Vec::collect() |
1-Core AoS + Heap | 70.66 ms |
1.13 GB/s |
0.10x |
1.00x |
[B] Idiomatic Rust SoA (filter().map().sum()) |
1-Core SoA Iterator | 19.12 ms |
4.18 GB/s |
0.38x |
3.70x |
[C] Hand-Written C/Rust 8-Accumulator SoA |
1-Core 8-Lane Unrolled | 7.32 ms |
10.92 GB/s |
1.00x (Baseline) |
9.65x |
[D] Rul (.rl) Tier 2 Fused SIMD |
1-Core L1-Tile SIMD (SimdStream) |
5.91 ms |
13.53 GB/s |
1.24x (1-Core vs. 1-Core) |
11.95x |
[E] Rul (.rl) Tier 2 MultiCore |
All Cores (MultiCore 1-Byte Hint) |
3.19 ms |
25.04 GB/s |
2.29x (Schedule Mutation) |
22.12x |
[F] Rul (.rl) Tier 2 MultiCore + ZoneMap |
All Cores + O(1) Tile Skipping |
1.55 ms |
51.53 GB/s |
4.72x (With Block Min/Max) |
45.51x |
Notes on the numbers above:
[C]vs.[D](1.24x) is the strict single-core comparison on the exact same80 MBarray.[E](2.29x) changes only the 1-byteScheduleHintfrompol=simd(0x11) topol=multicore(0x12), parallelizing 1,024-element L1 tiles across cores.[F](4.72x/51.53 GB/slogical bandwidth) adds block min/max metadata (ArenaZoneMap) on partitioned data so cold 1,024-element tiles that cannot match the filter are skipped inO(1)without reading them from RAM.
On deep arithmetic pipelines (BM-HORNER-50, a 50-step Horner polynomial with 104 SSA nodes over 10,000,000 f64 elements), the linear-scan YMM register allocator in src/aot.rs compiles a 3,872-byte ELF64 binary in ~20.4 us and executes in 106.58 ms, matching hand-written 8-accumulator C/Rust (107.96 ms).
A common question is: "If humans do not write .rl code, how do teams debug or maintain a system over time?"
- Humans Define the Boundaries; AI Agents Regenerate the Binary:
- Human engineers define the input/output schemas (
ArenaDescriptor), hardware permissions (CapabilityMask), and output assertions (AssertContract). - Because verifying and compiling a
.rlmodule takes microseconds, you never patch old AI-generated code. When requirements change, the AI regenerates the.rlmodule and verifies it from scratch.
- Human engineers define the input/output schemas (
- Scheduling is Separate from Logic:
- In C or Rust, adding SIMD intrinsics, cache tiling, and multi-threading tangles hardware tuning with business logic.
- In Rul, the operation (
opcode,in_a,in_b), the CPU schedule (schedule_hint), and the safety tags (proof_idx,token_op) sit in separate fields of each 16-byte instruction. Runningrul autotuneupdates only the schedule byte.
- Built-In Step-by-Step Inspection (
rul trace,rul decompile,rul inspect):- At any time, engineers can run
rul decompileto view the readable.rlslisting orrul traceto inspectmin,max,sum,NaN/Infcounts, and sample values at every instruction node#0..#N-1.
- At any time, engineers can run
We intentionally restricted v0.1 through v0.4.0 to array and vector dataflow pipelines (29 opcodes at the v0.4.0 release) to prove the 16-byte binary instruction format, single-pass O(N) verifier, and zero-LLVM native ELF64 compiler on real hardware first.
Milestone 1 (v0.5.0 — Turing-Complete Core) is now shipped across a 60-opcode 128-bit ISA: structured control flow (Block, Loop, If, Else, End, Br, BrIf), typed scalar locals, CAP_DIVERGE termination policy, I64/U8 bitwise & checked arithmetic, statically declared growable regions (mmap/mremap) with byte I/O and proof-based bounds elision, a modular function table with CAP_DIVERGE-gated recursion under host-independent call-depth and stack-unit budgets, and a single-pass linear-scan scalar register allocator (10 GPRs + 14 XMMs). All five v0.5 exit programs (Brainf*ck interpreter, recursive fib, quicksort, prime sieve, and sha256) pass Tier 0 == ELF64 AOT byte-for-byte and run within 1.13x–1.98x of rustc -O (<= 2.0x gate) with O(N) codegen (~32 ns/node).
We are executing a six-milestone roadmap (see ROADMAP.md) to expand Rul from a columnar compute engine into a general-purpose systems language capable of replacing Rust and Go for AI-generated software. Each milestone is defined by programs that must run identically in Tier 0 and as native binaries:
- Milestone 1 (
v0.5— Shipped): Turing-Complete Core- Integer and byte arithmetic, declared growable memory regions with runtime bounds checks, byte input and output, a function table with recursion guarded by host-independent call-depth and stack limits, and single-pass scalar register allocation. Exit programs passing
Tier 0 == ELF64 AOT(1.13x–1.98xvsrustc -O): a Brainf*ck interpreter written in Rul, recursivefib,quicksort, a primesieve, andsha256.
- Integer and byte arithmetic, declared growable memory regions with runtime bounds checks, byte input and output, a function table with recursion guarded by host-independent call-depth and stack limits, and single-pass scalar register allocation. Exit programs passing
- Milestone 2 (
v0.6): Ownership Across Joins, Linking & Standard Library- Region ownership and leases checked across branches, loops, and calls in
O(N), a constant data section, linking of separately verified modules, andVec,String, andHashMapwritten in Rul.
- Region ownership and leases checked across branches, loops, and calls in
- Milestone 3 (
v0.7): Capability-Gated Linux I/O & Columnar Bridge- File, clock, and network syscalls gated by fine-grained
CapabilityMaskbits, and a region-as-arena view so general programs call the columnar SIMD engine.
- File, clock, and network syscalls gated by fine-grained
- Milestone 4 (
v0.8): Thread-Per-Core Concurrency & Network Servers- Share-nothing worker tasks and typed channels that transfer region ownership across cores, with an HTTP key-value server benchmarked against Go and Rust.
- Milestone 5 (
v0.9): C ABI FFI & AI Synthesis BenchmarkCAP_FFI-gated calls into C libraries, verifier diagnostics with repair hints, and a measured first-shot code generation benchmark.
- Milestone 6 (
v1.0):AArch64Backend, Formal Proofs & Format Freeze- A second zero-LLVM native backend, continuous differential fuzzing, Kani proofs for the verifier, and the frozen
.rlv1.0format.
- A second zero-LLVM native backend, continuous differential fuzzing, Kani proofs for the verifier, and the frozen
| Dimension | C (clang -O3) |
Go (gc) |
Rust (rustc + LLVM) |
Rul (.rl) |
|---|---|---|---|---|
| Primary Author | Human programmer | Human engineering teams | Human systems engineers | AI Agents (with human-auditable tools) |
| Artifact Format | Text (.c, .h) |
Text (.go) |
Text (.rs) |
Flat Binary .rl (16-Byte Instructions) |
| Parse Overhead | High | Medium | Very High (Macros, AST) | 0 ms (Direct binary load) |
| Memory Safety | None (Manual pointers) | Garbage Collector | Borrow Checker (Constraint solver) | Versioned TokenOp (O(1) check per node) |
| Bounds Checking | Unchecked | Runtime branch per access | Runtime branch (unless elided) | Load-time Shape + ProofEntry table |
| Verify + Compile Time | Seconds | Sub-second to seconds | Seconds to minutes | ~5.8 ns/node Verify + ~6.4 us ELF64 AOT |
| Sandbox Security | Full OS process | Full OS process | Full OS process (unsafe crates) |
64-Bit CapabilityMask in File Header |
- 16-Byte Binary Format (
src/bytecode.rs) & Symbolic Assembler (src/transpiler.rs):- 64-byte
RulHeader, 16-byteArenaDescriptortable, 16-byteProofEntrytable, and 16-byteNodeFrameinstructions across 60 opcodes (30 columnar dataflow opcodes plus 30 structured control-flow, scalarI64/U8, growable region, and modular function opcodes). - Lossless
.rls<->.rlassembler and decompiler (assemble_rls,program_to_rls).
- 64-byte
- Single-Pass
O(N)Static Verifier (src/verifier.rs):- Checks acyclic instruction ordering (
in_a < idx), memory version transitions (AffineConsume/ReadLease), slice/gather/region bounds (ProofEntry),FuncSig/BlockSig/LoopBoundwitnesses, andCapabilityMaskpermissions in one pass.
- Checks acyclic instruction ordering (
- 3-Tier Execution Engine & Autotuner (
src/engine.rs):- Tier 0 (
execute_tier0_interpreter): Reference interpreter and golden oracle (including structured control flow, regions, and explicit heap-stack function calls). - Tier 1 (
execute_tier1_stencil): 8-lane vectorized column kernels. - Tier 2 (
execute_tier2_fused&execute_tier2_with_zonemap): L1-cache tile fusion (1,024elements/tile), multi-core execution, andArenaZoneMaptile skipping. - White-Box Tracer (
trace_program): Computes per-nodemin,max,sum,NaN/Infcounts, and sample values.
- Tier 0 (
- Direct Linux
x86_64AVX2 & ScalarELF64Compiler (src/aot.rs):- Emits standalone Linux
x86_64ELF64binaries in microseconds with zeroLLVMorlibcdependencies: 256-bit AVX2YMMlinear-scan allocation (ymm2..ymm13) + FMA3/vectorizedLn/Expfor columnar pipelines, and a single-pass linear-scan scalar allocator (10 GPRs + 14XMMs) with private guarded stack andmmap/mremapregions for Turing-complete programs.
- Emits standalone Linux
- Model Context Protocol Server (
src/mcp.rs&src/bin/rul_mcp.rs):- In-memory
stdioJSON-RPC 2.0 MCP server (rul-mcp) providing 6 tools for AI agents:rul_assemble_and_verify,rul_test_differential,rul_autotune_schedule,rul_compile_standalone,rul_trace, andrul_cas_intrinsics.
- In-memory
- Content-Addressed Intrinsics (
src/cas.rs) & Embedding API (src/ffi.rs):- 64-bit FNV-1a content-addressed store (
RulCasStore) withI64/U8kernels (sort,hash_join,group_by,simd_scan_byte,fnv1a_hash) and zero-panic#[repr(C)]embedding functions under#![forbid(unsafe_code)].
- 64-bit FNV-1a content-addressed store (
# Install from prebuilt release tarball or source
curl -fsSL https://raw.githubusercontent.com/rul-lang/rul/main/install.sh | sh
# Or build and install with Cargo
cargo install --git https://github.com/rul-lang/rul --bins --force
# CLI workflow
rul new my-ai-pipeline
cd my-ai-pipeline
rul check # Run single-pass O(N) static verifier
rul build # Assemble .rls -> build/main.rl and emit standalone ELF64 binary
rul run # Execute Tier 2 + ELF64 AOT with differential verification
rul trace # Print per-node min/max/sum/NaN inspection table
rul autotune # Sweep ScheduleHint policies and pick fastest schedule
# Run the full 10-pipeline differential and AOT benchmark suite
rul-bench
# Run the MCP server for AI agents
rul-mcp
# Run all unit, verifier, differential, and AOT tests
cargo testROADMAP.md: Six-Milestone Technical Roadmap from thev0.4Columnar Engine throughv0.5Turing-Complete Core to thev1.0General-Purpose Systems Language.docs/rul_spec_v0.md: Official.rlBinary Layout, 128-Bit Instruction Frame &O(N)Verifier Specification (v0.5.060-opcode ISA).docs/about_rul.md: Plain-English Overview of How Rul Works.docs/new_language_for_AI.md: Design Notes & Architectural Breakdown.docs/WHITEPAPER_RUL_V0_1.md: Technical Whitepaper & Empirical Evaluation (Zenodo Archive).docs/prior_art/: Cryptographic SHA-256 Prior Art Manifest & OpenTimestamps Proofs.
- License: Dual-licensed under either the MIT License or the Apache License, Version 2.0 at your option.
- Attribution: Redistributions must preserve the attribution notice in
NOTICE. - Trademark Policy: The "Rul" name, logo, and
RL_MAGICconformance mark are governed byTRADEMARK.md. - Citation: See
CITATION.cff.
Creator & Lead Architect: Tran Trong Tri (Tymon Tran) — <tymon3568@gmail.com>