Flux gives you direct control over memory, calling conventions, and machine code - with a syntax that doesn't get in the way. Everything is stack allocated unless you say otherwise.
Everything lives on the stack unless you explicitly heap-allocate. No garbage collector, no runtime overhead. You decide exactly where your data lives.
Flux compiles directly to LLVM IR, giving you access to all LLVM optimisation passes and every target architecture LLVM supports.
Drop into raw assembly anywhere in your program with asm { } blocks. Architecture-conditional via #ifdef. Works on x86-64 and ARM64.
Specify calling conventions per function. Mark functions extern for C interop or naked for full prologue/epilogue control.
First-class objects with method dispatch, operator overloading, and scoped namespaces. No inheritance — compose instead.
Pointers are first-class with explicit width: *[8]int is a pointer to an 8-bit int. Cast, dereference, and do arithmetic with full type safety.
struct Vec3 { float x, y, z; }; def main() -> int { Vec3 pos {x = 1.0, y = 2.0, z = 3.0}; Vec3 vel {x = 0.1, y = 0.0, z = -0.5}; pos.x += vel.x; return 0; };
object Counter { int value; def __init() -> this { this.value = 0; return this; }; def __expr() -> Counter* { return this; }; def __exit() -> void { (void)this; }; def inc() -> void { this.value++; }; def dec() -> void { this.value--; }; def get() -> int { return this.value; }; }; def main() -> int { Counter c(); c.inc(); c.inc(); c.inc(); return c.get(); };
def main() -> int { int x = 42; int* p = @x; *p = 100; // cast pointer to void* and back void* vp = (void*)p; int* p2 = (int*)vp; return *p2; };
def add_one(int n) -> int { asm { mov rax, [rbp-8] add rax, 1 mov [rbp-8], rax } return n; }; def main() -> int { return add_one(41); };
def max<T>(T a, T b) -> T { return a > b ? a : b; }; def main() -> int { int a = max(3, 7); float b = max(1.5, 2.5); return 0; };
#import <standard.fx>; using standard::io::console; def main() -> int { int score = 42; // f-string: interpolates into output println(f"Score: {score}"); // i-string: builds a string value byte* msg = i"Result={score}":{score;}; println(msg); return 0; };
Plain data structures with named fields. Stack-allocated by default, exact size deterministic at compile time. Zero runtime overhead — struct access compiles to direct memory offsets.
Flux requires Python 3.8 or newer and LLVM with Clang. On Ubuntu and Debian, both are available via apt.
The code generation backend uses llvmlite. Install version 0.43.0 - it matches LLVM 18 which ships with Ubuntu 24.04.
Flux is open source. The repository includes the compiler, standard library, and examples.
Run fxc.py on any .fx file. The output is a native binary - no runtime required to distribute or run it.