Documentation · Draft
DEXA Language Overview
This is an early draft of the DEXA language. The syntax and semantics below are not stable and will change as the compiler and type system solidify. Use this as a guide to the intent and shape of the language.
Status: Experimental · Compiler prototype in Rust · Contributions via GitHub.
New to the language surface? Start with the DEXA Language Tour, then come back here for details.
Getting started (prototype)
The reference compiler is being built in Rust. At this stage, DEXA is not ready for production workloads, but you can explore the syntax and contribute to the design.
- Clone the repository: git clone https://github.com/dxiv/dxa-dev
- Enter the compiler directory: cd compiler
- Run the prototype on an example: cargo run -- ../examples/hello.dexa
The current compiler can parse and typecheck a subset of the language: functions, blocks, let/let mut, if/else, loops, nominal records (model/contract), and the address type.
Example · Minimal program
fn add(a: int, b: int) -> int {
return a + b;
}
fn main() {
let three: int = add(1, 2);
return;
}
Core syntax
Functions
Functions are declared with fn, a name, parameters, an optional return type, and a block body.
fn sigmoid(x: float) -> float {
return 1.0 / (1.0 + exp(-x));
}
Statements
The prototype supports let bindings, return, expression statements, structured loops, and basic if/else control flow.
fn step() {
let lr: float = 0.01;
let loss: float = compute_loss();
if loss > 0.0 {
update_weights(lr, loss);
}
}
Types
Primitive types
- int — fixed-width integer
- float — floating point value
- bool — true/false
- string — UTF-8 string
- unit — “no value”, used when functions don’t return anything
- address — concrete address / identity type used by models and contracts.
address is a real type (not an alias of string). Conversions must be explicit via address("..."); there are no implicit coercions.
Planned core types
- tensor<T, shape> — n-dimensional tensors for AI/ML.
- asset<T> — tracked assets for contracts.
- model — model definitions bound to tensor graphs.
- contract — verifiable, deterministic contract units.
Tensor and asset types are not fully implemented yet, but the syntax and semantics are being designed in parallel with the compiler.
Execution model (prototype)
Pipeline
- Source .dexa → tokens (lexer).
- Tokens → AST (functions, blocks, if/else, expressions).
- AST → typechecked tree (primitives + nominal record types).
- AST → DX-IR (locals, blocks, If, While, Loop, Return, calls, binary ops, records).
- IR validation → fail-fast invariant checks (hard firewall before runtime).
- IR → ProgramResult via a small interpreter.
What this means today
- Running main produces a structured result, not just a raw integer.
- Every execution yields: value (return value), prints (captured print(...) calls), trace (function-level call trace), and gas (step counter).
- require(cond, msg?) is classified as a data result: if the condition is false you get ProgramResult::RequireFail with the failure message plus the trace/gas up to that point.
- print(expr) never writes directly to stdout; it appends rendered output to prints in order.
- Records are nominal. Record literals are materialized during lowering (defaults applied there), and the runtime does not “fill in” missing fields.
- The gas model is intentionally simple: each statement, expression, and function entry increments a deterministic counter.
DX-IR + IR validation + ProgramResult is the semantic contract for the language: future backends have to preserve “same code, same ProgramResult” for a given input.
Compiler & language roadmap
Now
- Lexer & parser for functions, models, and contracts.
- Functions, blocks, if/else, loops (
while/loop). let/let mut, assignments, block scopes & shadowing.- Primitive typechecker + nominal record types +
address+ explicitaddress("..."). - DX-IR + interpreter returning structured
ProgramResult. - IR validation pass to enforce invariants before runtime.
Next
- Richer diagnostics (multi-line snippets, better error codes).
- First-class collections (arrays/slices) as a stepping stone toward tensors.
- CLI polish: JSON output for
ProgramResult, better failure codes. - Minimal stdlib surface:
debug, small helpers on top of the core.
Later
- Tensor types and GPU backend integration.
- Contract subset and DX-VM.
- Playground & full docs site with examples and guides.
Contributing
If you have opinions about type systems, determinism, GPU backends, or contract safety, you’re the target audience. The fastest way to influence DEXA is to show up while it’s still being carved out.
Discuss design and implementation via GitHub issues or message DX directly on Discord / Telegram.