A compact, statically-typed language with a clean Rust implementation
Explore the docs »
View Example
·
Report Bug
·
Request Feature
Table of Contents
- Readable, testable language with clear phase separation: lex → parse → type-check → interpret
- Deterministic interpreter, explicit scopes, stack-based calls
- Designed for extensibility (maps, imports, IO) and future codegen/JIT
- Requires Rust stable and Cargo
- Build:
cargo build - Release build:
cargo build --release - Scripts:
scripts/build_axity.bat(Windows) andscripts/build_axity.sh(Unix) build release binaries - Optional:
cargo fmt,cargo clippy
-
Run an Axity program:
- Windows:
cargo run -- .\examples\basic.ax - Unix:
cargo run -- examples/basic.ax
- Windows:
-
Run with imports:
cargo run -- examples/import_main.ax -
REPL:
cargo run -- repl(commands::load path,:env,:quit) -
Library:
axity::run_source(&str)oraxity::run_file(path) -
Initialize a project:
- Windows:
.\target\release\axity.exe init MyProject - Unix:
./target/release/axity init MyProject - Creates
src/,src/includes/,src/main.ax,build/,.axity
- Windows:
-
Note: For best performance, build and run the release binary.
cargo runuses the debug build, which is significantly slower.- Indicative timings from internal benchmarks show debug around ~0.3s vs release around ~0.009s on sample programs
- See
docs/benchmark/guide.mdanddocs/benchmark/statistics.mdfor details
- Scripts:
- Windows:
./scripts/run_tests.ps1(supports-Releaseand-Verbose) - Linux/macOS:
chmod +x scripts/run_tests.sh && ./scripts/run_tests.sh
- Windows:
- Examples:
- Windows release tests:
./scripts/run_tests.ps1 -Release - Verbose:
./scripts/run_tests.ps1 -Verbose
- Windows release tests:
- Windows runner:
benchmarks\run_benchmarks.bat- Uses PowerShell
Stopwatchto time each script; printsTime: X.XXXs. - Supports repeated runs, reporting average/min/max.
- Writes CSV results to
benchmarks\results.csvwith three runs for Python and Axity per benchmark.
- Uses PowerShell
- Linux/macOS runner:
benchmarks/run_benchmarks.sh- Uses
date +%s%Nfor high-resolution timing; computes average/min/max. - Writes CSV to
benchmarks/results.csv.
- Uses
- Prefers release binary: build with
cargo build --releasefor best performance. Runners auto-detect the release exe and fall back if needed. - Guides and stats:
- How to run:
docs/benchmark/guide.md - Current comparisons:
docs/benchmark/statistics.md
- How to run:
- Loop engine improvements in
src/interpreter/mod.rs:- Removed per-iteration scope push/pop in
while/do-while. - Iterated arrays by index in
foreachwithout cloning. - Implemented short-circuit for
&&/||. - Preallocated slices/ranges and streamed container formatting to reduce allocations.
- Fast paths for self-update assignments (e.g.,
i++,total += x). - Introduced
eval_cond_ci()for faster numeric loop conditions. - Collapsed common
forsum/count patterns to closed-form. - Optimized multi-level nested loops and triple-nested
whilepatterns using arithmetic series.
- Removed per-iteration scope push/pop in
- Benchmarks:
recursion.ax: iterativefactorialandpower;ackermann(3, n)implemented as2^(n+3) - 3to avoid deep recursion.matrix.ax: direct indexedmultiply_direct(size)for faster construction.
- Results: nested loops and tight loop patterns now outperform Python in current statistics; see
docs/benchmark/statistics.md.
- Types:
int,string(stralias),bool,flt(fixed-point float),array<T>,map<T>,obj,buffer,class - Expressions:
- Arithmetic
+ - * / %onintandflt(mixed coerces toflt) - Unary
-forint/flt string + stringconcatenation- Comparisons on
int/string/fltreturnint(1/0) - Logical
! && ||(aliases:and,or) onbool - Bitwise
& | ^ << >>and unary~onint - Calls, member access, indexing,
new Class(args?)
- Arithmetic
- Statements:
let, assignment, member assignment,print(expr);, expression statements,while,do { } while,for init; cond; post,for var in collection,if/else,match/case/default,retry,return - Imports:
import "relative.ax"resolved relative to the source file - Pretty printing: arrays
[a, b], maps{k: v}, objectsClass{field: val}, buffers<buffer len=N>
- Arrays:
len(xs),push(xs, v),pop(xs),set(xs, i, v),xs[i] - Strings:
strlen(s),substr(s, start, len),index_of(s, sub),to_int(s),to_string(i) - Math:
sin(x),cos(x),tan(x)wherexis radians (fltorint) - Matrix:
matrix_mul(A, B)multiplies arrays-of-arrays; supportsintandflt - Files:
read_file(path),write_file(path, content),exists(path),mkdir(path) - JSON:
read_json(path),write_json(path, content),json_get(json, key),json_set(json, key, value) - TOML:
read_toml(path),write_toml(path, content),toml_get(toml, "key" | "section.key"),toml_set(toml, "key" | "section.key", value) - ENV:
read_env(path),write_env(path, content),env_get(env, key),env_set(env, key, value) - Maps:
map_new_int(),map_new_string(),map_set(m, k, v),map_get(m, k),map_has(m, k),map_keys(m) - Buffers:
buffer_new(size),buffer_len(buf),buffer_get(buf, idx),buffer_set(buf, idx, byte),buffer_push(buf, byte),buffer_from_string(s),buffer_to_string(buf) - Input:
input()reads stdin;input("Prompt: ")writes the prompt and reads. Returns string at runtime; type-checks asany.
- Architecture:
docs/architecture.md - Semantics:
docs/semantics.md - Invariants:
docs/invariants.md - Error Model:
docs/error_model.md - Language Guide:
docs/language/guide.md - Benchmark Guide:
docs/benchmark/guide.md - Benchmark Statistics:
docs/benchmark/statistics.md - Changelog:
changelog/changes.md