Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Crush Overview

Verified against crush-ast v0.13.0 (dc0d0278, 2026-12-03).

Crush is a small, capability-based scripting language with polyglot blocks, and the toolchain around it: a parser, a compiler to bytecode, a sandboxed VM, and an intermediate representation (CAST) that other languages can be translated into. It is alpha software — this guide documents what runs today and says so when something doesn’t.

What Crush is

  • A language. let, fn, if/while/for, match, try/catch, arrays and objects, closures and function values, structs with impl methods and traits, green tasks, a pipeline operator. Dynamically typed at run time with optional compile-time type hints. See Syntax.
  • Capability-gated. A program can’t print files, open sockets or start processes unless the host turns the matching capability on. Capability calls are ordinary dotted calls — fs.read("x"), io.print("y"). See Capability System.
  • Polyglot. @python -> out { }, @javascript { } and @bash { } blocks run other languages and exchange variables with Crush. They currently run as ordinary subprocesses outside the capability model unless you build the optional sandbox. See Polyglot Programming.
  • A pipeline. Source becomes CAST (an AST in JSON), then CASM (bytecode), then runs on a VM (crush-vm), with a faster VM, a JIT and ahead-of-time backends also in the repository (Engines, AOT and Walkers). Walkers translate Python, JavaScript, Rust and other languages into the same CAST.

New since 0.9.0

Up to the pinned commit (v0.13.0); each item links to its page.

  • Imports and packages. import a.b [as x] [{ f }] loads .crush files at compile time, through -L, CRUSH_PATH and crush-pkg dependencies; pub fn is enforced per package (since v0.12.0) and a dependency’s own dependencies resolve (v0.13.0); a struct or trait name declared in two files is a compile error. (Modules)
  • catch catches run-time faults: division by zero, a bad index, a failing capability. (Control Flow)
  • Calls on any expression (fs[0](1), make()(2), S { n: 3 }.size()), the method form a.pop(), regex.match callable, exponent literals (1.5e3). (Closures, Types)
  • process.exec returns a map {exit_code, stdout, stderr}. (Capability System)
  • Quotas and networking. --max-wall-ms N|unlimited bounds the whole run, --max-steps unlimited; net.* and tcp.recv/tcp.accept take {timeout_ms}; net.http_request returns response headers. (Capability System)

New in 0.9.0

Each item links to the page that documents it (and every example there was run).

  • Slices on strings, and steps. s[0:5], s[-5:], s[::2], s[::-1] on strings and arrays; they lower to seq.slice. (Types)
  • Hex and binary literals. 0xff, 0b101. (Syntax)
  • A debugger. crush debug FILE --step --inspect: breakpoints by line, step, watch, print, with the inspection itself a grant. (Debugging)
  • Windows. crush gui run FILE --ui and the ui.* API, from the separate crush-gui package. (Windows)
  • Raw sockets. tcp.* behind --tcp (client) and --tcp-listen (server); --net stays HTTP-only. net.* is compiled into the default build, and the old http.* names are refused with their replacement. (Capability System)
  • One diagnostics format. --message-format json gives one schema across the tools, and semantic errors carry a line and column. (Diagnostics)
  • Easier install. cargo install crush-lang-sdk (not cargo install crush, which is an unrelated crate), or the prebuilt Linux binaries on the GitHub release; v0.9.0 is the first release to have them. (Getting Started)
  • @bash blocks can read Crush variables again, by $name. (Polyglot)

Hello, Crush

print("Hello, Crush!")
Hello, Crush!

Run it with the toolchain built from crush-ast (see Getting Started):

crush run hello.crush

A taste

struct Point { x: Int, y: Int }
impl Point {
    fn distance_sq(self) { return self.x * self.x + self.y * self.y }
}

let points = [Point { x: 3, y: 4 }, Point { x: 1, y: 1 }]
let far = |p| p.distance_sq() > 10
let i = 0
while i < len(points) {
    let p = points[i]
    if far(p) {
        print("far: " + p.distance_sq())
    }
    i = i + 1
}
far: 25

Security model, in short

  1. Deny by default. Every capability group (--fs, --net, --process, --polyglot, …) is off until you enable it on the command line (or register it, when embedding).
  2. Quotas. Instruction count, stack depth, output size, call depth and wall-clock time for polyglot blocks are bounded.
  3. Honest limits. Polyglot blocks run with the host’s authority in the default build; the bubblewrap sandbox is opt-in at build time. The capability chapter lists what is not enforced.

Where things stand

AreaStatus
Core language (functions, loops, try/catch, match)works
Closures and function valuesworks on the VM; AOT refuses them by name
Structs, impl, trait, @kind, struct patternsworks on the VM; AOT refuses method calls by name
spawn / yield / await, parallel_mapworks on the VM
import (multi-file programs), crush-pkg packagesworks, resolved at compile time; visibility is per package, a private function used from another package is the warning W-VIS01 (Modules)
Capabilities, @capabilities, the standard libraryworks; the standard library is on by default
Polyglot: Python, JavaScript (declared -> outputs), Bashworks (host authority by default); @bash reads the Crush variables it names as $name
Polyglot sandboxopt-in build, verified on Linux with bwrap
CAST / CASM formatsdocumented in their own sections

Next Steps