axon-lang
AI-Native eXecution Optimized Notation
A programming language designed for AI models to write hyper-efficient native applications. Humans canβt easily read or write it β thatβs the point.
What is AXON?
Section titled βWhat is AXON?βAXON is a compiler-first, AI-native programming language. It is not designed for human programmers. It is designed to be the output target when an AI model generates high-performance native code.
Traditional programming languages optimize for human readability β meaningful variable names, familiar syntax sugar, implicit conversions, flexible formatting. AXON strips all of that away. What remains is a minimal, unambiguous, fully-explicit notation that a language model can emit deterministically, and a compiler can transform into optimal machine code with zero guesswork.
The current source format is S-expressions (.axs files) β a fully parenthesized prefix notation that eliminates parsing ambiguity. Phase 2 introduces a binary AST format (.axb files) that removes lexing and parsing entirely: the AI emits a token stream of opcodes, type indices, and De Bruijn variable references that the compiler can consume in a single linear pass.
Key Features
Section titled βKey Featuresβ| Feature | Description |
|---|---|
| Dual Source Format | S-expression text (.axs, Phase 1) + Binary AST (.axb, Phase 2) |
| Module System | (import) / (use) with visibility enforcement (pub) and qualified access |
| Linear Type System | No garbage collector β compile-time memory management (Phase 2) |
| Dual Backend | QBE IL for fast dev builds, LLVM IR for optimized release builds |
| De Bruijn Scoping | Variable binding uses structural indices, not names (Phase 2) |
| Region-Based Memory | Arena allocation β bulk alloc, bulk free, zero fragmentation |
| Zero Runtime Overhead | No GC, no dynamic dispatch, no bounds checking |
| Cross-Platform | macOS (ARM64) and Linux (x86_64 / ARM64) |
| Explicit Everything | Every literal is typed, every conversion is explicit, no implicit coercions |
Quick Start
Section titled βQuick StartβPrerequisites
Section titled βPrerequisitesβ- A C11 compiler (
cc,gcc, orclang) - QBE (for QBE backend) or LLVM (for LLVM backend)
make- macOS (ARM64) or Linux (x86_64 / ARM64)
Build the Compiler
Section titled βBuild the Compilerβ# Clone the repositorygit clone https://github.com/axon-lang/axon.gitcd axon
# Build (debug mode)make
# Build (optimized)make releaseThis produces:
build/axoncβ the AXON compilerbuild/libaxon_rt.aβ the runtime library
Compile and Run an AXON Program
Section titled βCompile and Run an AXON Programβ# Compile to native binary (QBE backend, default)./build/axonc examples/fibonacci.axs -o fib./fib# Output: 9227465
# Compile with LLVM backend (optimized)./build/axonc examples/fibonacci.axs -o fib --backend llvm -O2
# Emit QBE IL (for inspection)./build/axonc examples/fibonacci.axs --emit qbe
# Emit LLVM IR (for inspection)./build/axonc examples/fibonacci.axs --emit llvm
# Type-check only (no code generation)./build/axonc examples/fibonacci.axs --check
# Compile and execute in one step β caches the binary for fast re-runs./build/axonc run examples/fibonacci.axs# Output: 9227465
# Same again β instant (cache hit)./build/axonc run examples/fibonacci.axs
# Optimised run./build/axonc run --release examples/fibonacci.axs
# Watch the import graph and rebuild on every save (Ctrl+C to stop; Linux only)./build/axonc build --watch examples/fibonacci.axs# [watch] watching 1 file (debounce 100ms) β press Ctrl+C to stop# [rebuild] fibonacci.axs β examples/fibonacci (took 210ms)# ...edit + save the file, and it rebuilds automatically...# [rebuild] fibonacci.axs β examples/fibonacci (took 118ms)# Rebuild-and-rerun loop, or a slower debounce, or JSON lines for tooling:./build/axonc run --watch examples/fibonacci.axs./build/axonc build --watch --watch-debounce=500 examples/fibonacci.axs./build/axonc build --watch --json examples/fibonacci.axs
# Emit machine-readable module metadata (functions, types, constants) as JSON./build/axonc introspect examples/fibonacci.axs --format=json
# Validate the whole standard library as a cheap CI gate (parse + type-check# every std/*.axs and verify each has a matching *.meta.json). The stdlib root# is the -L directory or $AXON_STDLIB. Exits non-zero on any failure../build/axonc --check-stdlib -L ../axon-std/std# Also cross-check that a program's std/* imports resolve to real modules:./build/axonc --check-stdlib -L ../axon-std/std myprog.axs --diagnostics-jsonSee docs/cli/run.md for the full axonc run reference,
docs/cli/introspect.md for axonc introspect, and
docs/cli/format.md for axonc format (style presets,
--check, --in-place, --diff).
Run Tests
Section titled βRun Testsβmake testShell Completions
Section titled βShell CompletionsβGenerate tab-completion scripts for your shell:
# Bash β add to ~/.bashrceval "$(axonc completions bash)"
# Zsh β add to ~/.zshrceval "$(axonc completions zsh)"
# Fish β add to ~/.config/fish/config.fishaxonc completions fish | source
# PowerShell β add to your $PROFILEaxonc completions powershell | Out-String | Invoke-Expression
# Nushell β save to a file and source itaxonc completions nushell | save -f ~/.cache/axonc-completions.nusource ~/.cache/axonc-completions.nuExample: Fibonacci
Section titled βExample: Fibonacciβ;; Compute fib(35) = 9227465(module (fn fib ((n i64)) i64 (if (lt n (i64 2)) n (add (call fib (sub n (i64 1))) (call fib (sub n (i64 2))))))
(fn main () i32 (block (call print_i64 (call fib (i64 35))) (i32 0))))Every integer literal has an explicit type annotation ((i64 2), (i32 0)). Every function specifies parameter types and a return type. There are no implicit conversions.
Example: Multi-File Imports
Section titled βExample: Multi-File Importsβ;; math.axs β a library module(module (pub (fn square ((x i64)) i64 (mul x x))));; main.axs β imports and uses the library(module (import math "math.axs")
(fn main () i32 (block (call print_i64 (call math.square (i64 7))) ;; prints 49 (i32 0))))Modules use (pub ...) to export functions and (import alias "path") for namespaced access, or (use "path" (fn1 fn2)) to import specific functions directly into scope.
Project Structure
Section titled βProject Structureβaxon/βββ Makefile # Build systemβββ README.md # This fileβββ docs/β βββ language-spec.md # Complete language specificationβ βββ ai-guide.md # AI agent programming guideβ βββ binary-format.md # Binary AST format specificationβ βββ examples/ # Example AXON programsβ βββ hello.axsβ βββ fibonacci.axsβ βββ calculator.axsβββ src/β βββ axon.h # Master header (all types & interfaces)β βββ main.c # Compiler driver & CLIβ βββ arena.c # Arena allocatorβ βββ diagnostics.c # Error reportingβ βββ lexer.c # S-expression lexerβ βββ parser.c # S-expression parser β ASTβ βββ ast.c # AST construction & printingβ βββ types.c # Type system & type tableβ βββ ir.c # IR construction & loweringβ βββ emit_qbe.c # QBE IL code generationβ βββ emit_llvm.c # LLVM IR code generationβββ runtime/β βββ rt.c # Runtime library (print_i64, etc.)βββ stdlib/ # Standard library (future)βββ tests/ βββ programs/ # Test programs (.axs files)Compiler Pipeline
Section titled βCompiler Pipelineβ.axs text βββΊ Lexer βββΊ Parser βββΊ AST βββΊ TypeChecker βββΊ Typed AST βββΊ IR Lowering βββΊ AXON IR βββΊ (Optimizer) βββΊ QBE IL / LLVM IR βββΊ native binary- Lexer β Tokenizes S-expression source into a flat token stream
- Parser β Builds an AST from the token stream
- Type Checker β Resolves types, enforces type rules, fills in type annotations
- IR Lowering β Transforms the typed AST into SSA-form IR (alloca/load/store)
- Optimizer β Runs optimization passes on the IR (optional,
-O1/-O2) - Backend β Emits QBE IL or LLVM IR from the optimized IR
- Assembler/Linker β QBE or LLVM toolchain produces the native binary
Phase Roadmap
Section titled βPhase RoadmapβPhase 1 β Foundation β COMPLETE
Section titled βPhase 1 β Foundation β COMPLETEβ- Arena allocator
- String interning
- S-expression lexer
- S-expression parser
- AST representation
- Type system (primitives, pointers, arrays, structs, functions)
- Type checker
- SSA IR (alloca/load/store style)
- IR lowering (AST β IR)
- QBE backend
- LLVM backend
- Runtime library (print_i64, print_f64, print_str, print_bool)
- End-to-end compilation to native binary
- Test suite (52 E2E tests, 6 error tests)
- Struct literals (
new) - Array literals (
arr.new) - Const declarations (
const) - Short-circuit evaluation (
land,lor) - Pointer operations (
addr,deref) - Module imports (
import,use,pubvisibility)
Phase 2 β Binary AST & Linear Types (current)
Section titled βPhase 2 β Binary AST & Linear Types (current)β- Binary AST format (
.axb) β AI emits opcodes directly - De Bruijn indices for variables (no name resolution needed)
- Linearity annotations (
@once,@maybe,@many) - Memory region annotations (
@region,@arena,@pool,@stack) - Layout annotations (
@soa,@align,@hot/@cold) - Constant folding & dead code elimination
- Inlining pass
Phase 3 β Concurrency & Error Handling
Section titled βPhase 3 β Concurrency & Error Handlingβ- Structured concurrency (
spawn,join,select) - Actor-based message passing
- Result types for error handling (
ok/err) - Pattern matching on result types
Phase 4 β Standard Library & Ecosystem
Section titled βPhase 4 β Standard Library & Ecosystemβ- Core data structures (vec, map, set)
- I/O library (files, sockets, stdio)
- String library (UTF-8, formatting)
- Math library
- Memory profiling tools
- Language server (for AI agent integration)
Phase 5 β Cross-Platform GUI
Section titled βPhase 5 β Cross-Platform GUIβ- Platform Abstraction Layer (
libaxon_palβ window, events, input) - macOS backend (AppKit via Objective-C runtime)
- Linux backend (X11/Wayland)
- Windows backend (Win32)
- Software 2D renderer (shapes, text, images)
- GPU backends (Metal for macOS, Vulkan for Linux/Windows)
- Flexbox layout engine
- Immediate-mode UI framework (
axon.uimodule) - Standard widget library (17+ widgets)
- Dark/Light/Custom theming
- App bundling (
.app,.desktop,.exe) - Hot-reload development mode
Benchmarking
Section titled βBenchmarkingβThe project includes a benchmark suite for measuring compiler and runtime
performance. See benchmarks/README.md for full details.
# Run all benchmarks (results as JSON to stdout)python3 scripts/run_benchmarks.py
# Run with 5 samples and save resultspython3 scripts/run_benchmarks.py --samples 5 --output benchmarks/baseline.json
# Compare against a baseline (exits 1 on regression)python3 scripts/run_benchmarks.py --baseline benchmarks/baseline.jsonBenchmarks include: recursive/iterative Fibonacci, Sieve of Eratosthenes, allocation stress, binary trees, bubble sort, arithmetic loops, and nested loops.
Documentation
Section titled βDocumentationβ| Document | Description |
|---|---|
| Language Specification | Complete grammar, type system, and semantics |
| AI Programming Guide | How to write AXON programs (for AI models) |
| Binary Format Spec | Phase 2 binary AST wire format |
| GUI Architecture | Cross-platform GUI framework design |
License
Section titled βLicenseβMIT License. See LICENSE for details.
Copyright (c) 2026 AXON Project.