Skip to content

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.


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.

FeatureDescription
Dual Source FormatS-expression text (.axs, Phase 1) + Binary AST (.axb, Phase 2)
Module System(import) / (use) with visibility enforcement (pub) and qualified access
Linear Type SystemNo garbage collector β€” compile-time memory management (Phase 2)
Dual BackendQBE IL for fast dev builds, LLVM IR for optimized release builds
De Bruijn ScopingVariable binding uses structural indices, not names (Phase 2)
Region-Based MemoryArena allocation β€” bulk alloc, bulk free, zero fragmentation
Zero Runtime OverheadNo GC, no dynamic dispatch, no bounds checking
Cross-PlatformmacOS (ARM64) and Linux (x86_64 / ARM64)
Explicit EverythingEvery literal is typed, every conversion is explicit, no implicit coercions
  • A C11 compiler (cc, gcc, or clang)
  • QBE (for QBE backend) or LLVM (for LLVM backend)
  • make
  • macOS (ARM64) or Linux (x86_64 / ARM64)
Terminal window
# Clone the repository
git clone https://github.com/axon-lang/axon.git
cd axon
# Build (debug mode)
make
# Build (optimized)
make release

This produces:

  • build/axonc β€” the AXON compiler
  • build/libaxon_rt.a β€” the runtime library
Terminal window
# 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-json

See 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).

Terminal window
make test

Generate tab-completion scripts for your shell:

Terminal window
# Bash β€” add to ~/.bashrc
eval "$(axonc completions bash)"
# Zsh β€” add to ~/.zshrc
eval "$(axonc completions zsh)"
# Fish β€” add to ~/.config/fish/config.fish
axonc completions fish | source
# PowerShell β€” add to your $PROFILE
axonc completions powershell | Out-String | Invoke-Expression
# Nushell β€” save to a file and source it
axonc completions nushell | save -f ~/.cache/axonc-completions.nu
source ~/.cache/axonc-completions.nu
;; 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.

;; 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.

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)
.axs text ──► Lexer ──► Parser ──► AST ──► TypeChecker ──► Typed AST
──► IR Lowering ──► AXON IR ──► (Optimizer) ──► QBE IL / LLVM IR
──► native binary
  1. Lexer β€” Tokenizes S-expression source into a flat token stream
  2. Parser β€” Builds an AST from the token stream
  3. Type Checker β€” Resolves types, enforces type rules, fills in type annotations
  4. IR Lowering β€” Transforms the typed AST into SSA-form IR (alloca/load/store)
  5. Optimizer β€” Runs optimization passes on the IR (optional, -O1/-O2)
  6. Backend β€” Emits QBE IL or LLVM IR from the optimized IR
  7. Assembler/Linker β€” QBE or LLVM toolchain produces the native binary
  • 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, pub visibility)
  • 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
  • Structured concurrency (spawn, join, select)
  • Actor-based message passing
  • Result types for error handling (ok/err)
  • Pattern matching on result types
  • 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)
  • 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.ui module)
  • Standard widget library (17+ widgets)
  • Dark/Light/Custom theming
  • App bundling (.app, .desktop, .exe)
  • Hot-reload development mode

The project includes a benchmark suite for measuring compiler and runtime performance. See benchmarks/README.md for full details.

Terminal window
# Run all benchmarks (results as JSON to stdout)
python3 scripts/run_benchmarks.py
# Run with 5 samples and save results
python3 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.json

Benchmarks include: recursive/iterative Fibonacci, Sieve of Eratosthenes, allocation stress, binary trees, bubble sort, arithmetic loops, and nested loops.

DocumentDescription
Language SpecificationComplete grammar, type system, and semantics
AI Programming GuideHow to write AXON programs (for AI models)
Binary Format SpecPhase 2 binary AST wire format
GUI ArchitectureCross-platform GUI framework design

MIT License. See LICENSE for details.

Copyright (c) 2026 AXON Project.