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.
#import "standard.fx"; namespace hello { object Greeter { void greet(void) { std::io::println("Hello, World!"); } }; int main(void) { Greeter g = new Greeter(); g.greet(); return 0; } }
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; float y; float z; }; int main(void) { Vec3 pos = {1.0, 2.0, 3.0}; Vec3 vel = {0.1, 0.0, -0.5}; pos.x += vel.x; return 0; }
object Counter { int value = 0; void inc(void) { this.value++; } void dec(void) { this.value--; } int get(void) { return this.value; } }; int main(void) { Counter c = new Counter(); c.inc(); c.inc(); c.inc(); return c.get(); }
int main(void) { int x = 42; *int p = &x; *p = 100; // typed width pointer *[8]int bp = (*[8]int)&x; return x; }
int add_one(int n) { asm { "mov rax, [rbp-8]"; "add rax, 1"; "mov [rbp-8], rax"; } return n; } int main(void) { return add_one(41); }
template<T> T max(T a, T b) { return a > b ? a : b; } int main(void) { int a = max(3, 7); float b = max(1.5, 2.5); return 0; }
#import "standard.fx"; int main(void) { int score = 42; // f-string: prints directly f"Score: {score}\n"; // i-string: builds a value char* msg = i"Result={score}"; std::io::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.