46. Documentation
Glossary
A reference of 50+ terms used in the Braid language and compiler ecosystem.
A
- ARC
- Automatic Reference Counting. Braid's primary memory management strategy where each heap object tracks its reference count. Objects are freed when their count reaches zero. Combined with cycle detection for handling reference cycles.
- AST
- Abstract Syntax Tree. The tree representation of Braid source code produced by the parser. Nodes include
AST_FN_DECL,AST_VAR_DECL,AST_BINARY_OP, etc. - Autograd
- Automatic differentiation. A
@autograddecorator that marks a function for gradient computation. Builds a computation graph during forward pass and computes gradients during backward pass. - Autocatalytic Recursion
- A self-referential code optimization technique where recursive function patterns bootstrap their own optimization. Each recursion level generates progressively more optimized code.
B
- Bond
- Braid's UI component framework (like React). Uses components with state, props, and lifecycle for building interactive web UIs.
- Blend
- Braid's styling system (like CSS-in-JS). Provides scoped styles, responsive design, and theme integration.
- Braidc
- The Braid compiler CLI tool. Supports parse, ast, ir, ccodegen, build, run, frontend, and junction subcommands.
- Bytecode
- The compiled binary format (
.bx) containing BraidVM instructions. Headered with magic bytesBRDC.
C
- CCodegen
- The C code generation backend. Converts Braid AST to C source code, which is then compiled with GCC into a native executable.
- Closure
- A function value that captures variables from its enclosing scope. Implemented in the VM via
OBJ_CLOSUREwith upvalues. - Compiler Pipeline
- The sequence of stages: Source → Lexer → Parser → AST → Type Checker → CCodegen/LLVM/MLIR → Output.
- Cycle Detection
- Part of Braid's memory management. Periodically traverses object graph to find and collect reference cycles that ARC cannot resolve.
D
- DTS
- Distinction Tree System. A multi-dimensional branching construct that organizes conditions into a tree of distinctions. Used in type checking, tensor dispatch, and web routing.
- Diameter Logic
- Dialectical reasoning primitive. A Diameter models tension between two poles (thesis/antithesis) with
evolve()andobserve()operations. - Dialectical Synthesis
- The process of resolving pole tension in a Diameter into a synthesized output. The synthesis emerges from the interaction of opposing forces over multiple evolution steps.
- Distinction Tree
- See DTS. A tree structure for multi-axis matching across types, values, shapes, and other dimensions simultaneously.
E
- Evolve
- A Diameter operation that advances the dialectical state. Can be called as
diameter.evolve()orevolve(diameter). - Extern
- A declaration keyword for C FFI.
extern fn sqrt(x: float) -> floatbinds to a C function at link time.
F
- FFI
- Foreign Function Interface. Braid supports two FFI mechanisms:
extern fn(compile-time C linking) andnative fn(runtime VM linking).
G
- Generational GC
- A garbage collection strategy where objects are classified by age (young/old). Young objects are collected frequently; old objects are promoted and collected less often. Braid's runtime uses this optionally alongside ARC.
- Green Threads
- Lightweight user-space threads managed by the Braid runtime, not the OS. Spawned via the
spawnkeyword for concurrent execution.
H
- Hindley-Milner
- The type inference algorithm used by Braid. It infers types without requiring explicit annotations by solving type constraints through unification.
- Hierarchical Head
- A concept from Braid's compiler architecture — the top-level module/function that serves as the entry point for supercompilation and polyhedral analysis.
I
- IR
- Intermediate Representation. Braid's SSA-like instruction format used between the AST and codegen stages. Opcodes include
ConstantI64,AddI64,Call,Branch, etc. - IRBuilder
- The C++ class that constructs Braid IR instructions programmatically. Used by the AST lowering pass to translate Braid AST nodes into IR.
J
- JL Sketch
- JL (Junction Language) Sketch — a shorthand notation used in the Junction web framework for defining routes, policies, and data models.
- Junction
- Braid's full-stack web framework. Supports creating complete web applications with routing, storage, auth, and background jobs.
L
- LLVM
- Low Level Virtual Machine. The planned backend for native code generation. Currently a stub —
braidc llvmoutputs mock LLVM IR. - Local Learning
- An ML training approach supported by Braid's Diameter construct where each layer learns locally via dialectical optimization rather than global backpropagation.
- LoRA
- Low-Rank Adaptation. An ML fine-tuning technique for large language models. Braid's tensor runtime supports LoRA-style weight updates via low-rank decomposition.
- Link
- Braid's client-side router for Bond applications. Supports declarative routing with nested layouts and lazy loading.
M
- MLIR
- Multi-Level Intermediate Representation. A framework for building reusable and extensible compiler infrastructure. Braid's MLIR backend is under development (currently a stub).
- Merge
- Braid's state management library (like Redux). Provides stores, actions, reducers, and selectors for managing application state in Bond apps.
N
- Native
- A keyword for declaring runtime FFI functions.
native fn print_int(val: int)links to C functions embedded in the BraidVM binary.
O
- Observe
- A Diameter operation that reads the current state. Supports
"tension"(0.0-1.0),"state"(current value),"pole_a", and"pole_b". Called asdiameter.observe("tension")orobserve(diameter).
P
- Pole
- One side of a Diameter's dialectical tension. Each pole defines a force vector that pulls the system in a particular direction. A Diameter has exactly two poles (pole_a and pole_b).
- Polyhedral Optimization
- A compilation technique for optimizing loop nests using polyhedral representation. The
run_polyhedral_opt()pass applies tiling, vectorization, and parallelization.
R
- Resonance
- A property of a Diameter measured after multiple evolution steps. High resonance indicates the poles are in a stable, balanced state. Low resonance indicates active dialectical tension.
S
- Supercompilation
- A program optimization technique based on Turchin's algorithm. Braid's
run_supercompiler()pass specializes programs at compile time by partial evaluation, unfolding recursive calls with constant arguments, and eliminating dynamic dispatch.
T
- Ternary
- A packed data type (
TENSOR_TERNARY) for ternary values {-1, 0, +1} stored as 2-bit values. Used for quantized ML models and efficient weight storage. - Tensor
- N-dimensional array. Braid's native tensor type supports 0-d to 8-d arrays with syntax
[[1, 2], [3, 4]]. Supports slicing, device transfer, and GPU operations. - Tension
- The dialectical force between two poles in a Diameter. Measured as a float between 0.0 (balanced) and 1.0 (maximally tense). Drives the evolve operation.
- Type Checker
- The compiler stage that verifies type correctness using Hindley-Milner inference and unification. Reports type errors with source location information.
- Token
- The output of the lexer — a typed, positioned element of source text. Types include
TOK_FN,TOK_LET,TOK_NUMBER,TOK_STRING, etc.
U
- Unification
- The process of merging two types in the Hindley-Milner type checker. Creates parent links for type variables to resolve inferred types.
- Upvalue
- A variable captured by a closure from an enclosing scope. Managed by the VM via
OP_GET_UPVALUEandOP_SET_UPVALUEinstructions.
V
- Value
- The runtime representation of a Braid value. A tagged union with types
VAL_NIL,VAL_BOOL,VAL_INT,VAL_FLOAT, andVAL_OBJ(heap pointer). - VM
- Virtual Machine. Braid's stack-based bytecode VM executes
.bxfiles. Supports 50+ opcodes for arithmetic, control flow, closures, structs, tensors, and ML operations.