A modern systems programming language with explicit allocations, effortless concurrency, and memory safety by default.
Every allocation, mutation, and side effect is visible in code. There are no hidden costs. Write code that does exactly what it says.
Parallel constructs are first-class citizens. Write concurrent code that's both safe and performant with intuitive parallel for loops.
Strong type system and compile-time checks prevent common memory errors. Performance of systems programming without the crashes.
Write platform-specific code elegantly with built-in platform blocks that compile cleanly for each target.
High-level features compile to efficient machine code. No runtime overhead, no garbage collection pauses.
Write tests directly alongside code with integrated test blocks. Keep code reliable from day one without external tooling.
use std.arena;
use std.io;
model Node {
value: i32;
next: ref Node;
}
/// Allocate a new Node from the arena
def new_node(arena: ref Arena, value: i32): ref Node {
mut n: ref Node = Arena.alloc(arena, sizeof(Node));
n.value = value;
n.next = nil;
return n;
}
/// Push a new value to the front of the list
def list_push_front(head: ref Node, arena: ref Arena, value: i32): ref Node {
mut new_head = new_node(arena, value);
new_head.next = head;
return new_head;
}
def cross_platform_func() {
platform windows {
parallel for mut i = 0; i < 10; i++ {
println i;
}
}
platform posix {
parallel for mut i = 0; i < 10; i++ {
println i;
}
}
}
platform windows {
def some_function() {
println "hi from windows!";
}
}
platform posix {
def some_function() {
println "hi from posix!";
}
}
/// Process data in parallel across multiple threads
def parallel_processing(data: i32[], size: i32) {
parallel for mut i = 0; i < size; i++ {
data[i] = data[i] * 2;
}
}
/// Compute intensive operations benefit from parallelism
def matrix_multiply(a: f64[][], b: f64[][], n: i32) {
parallel for mut i = 0; i < n; i++ {
for mut j = 0; j < n; j++ {
mut sum = 0.0;
for mut k = 0; k < n; k++ {
sum = sum + a[i][k] * b[k][j];
}
}
}
}
/// Counts the live neighbors
def count_neighbors(grid: i32[height][width], x: i32, y: i32,
width: i32, height: i32): i32 {
mut count: i32 = 0;
for mut dy = -1; dy <= 1; dy++ {
for mut dx = -1; dx <= 1; dx++ {
if dx == 0 and dy == 0 { continue; }
val nx = x + dx;
val ny = y + dy;
if nx >= 0 and nx < width and ny >= 0 and ny < height {
count = count + grid[ny][nx];
}
}
}
return count;
}
/// Compute next generation
def next_generation(grid: i32[height][width],
new_grid: i32[height][width],
width: i32, height: i32) {
for mut y = 0; y < height; y++ {
for mut x = 0; x < width; x++ {
val neighbors = count_neighbors(grid, x, y, width, height);
if grid[y][x] == 1 {
new_grid[y][x] = (neighbors == 2 or neighbors == 3) ? 1 : 0;
} else {
new_grid[y][x] = neighbors == 3 ? 1 : 0;
}
}
}
}
enum State {
RUNNING,
CHANGING,
STOPPED
}
enum Result {
SUCCESS,
ERR,
PENDING
}
main {
mut fixed_state: State = State.CHANGING;
println State.RUNNING;
println fixed_state;
if fixed_state == State.CHANGING {
fixed_state = State.RUNNING;
println "State changed to RUNNING";
}
val result: Result = Result.SUCCESS;
println result;
}
Axe's platform blocks allow targeting multiple operating systems while maintaining clean, readable code. Write once, deploy anywhere.