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"; using standard::io::console; def main() -> int { // stack allocated — no hidden heap string greeting = "Hello, World!\n\0"; print(greeting); return 0; };
heap to opt into dynamic allocation explicitly. No hidden costs, no implicit constructors.volatile modifier prevents optimizer interference.__init and __exit lifecycle methods. Use defer to schedule cleanup at scope exit — deterministic, no GC.extern. Supports cdecl, stdcall, fastcall, thiscall, and vectorcall calling conventions. Name mangling control with !!.be16, be32, be64, le16, le32, le64 types. Network and hardware programming without manual byte-swapping.object Counter { int value; def __init(int start) -> this { this.value = start; return this; }; def __exit() -> void { return; }; def inc() -> void { this.value += 1; return; }; def get() -> int { return this.value; }; }; def main() -> int { Counter c = 0; defer c.__exit(); c.inc(); c.inc(); c.inc(); print(c.get()); return 0; };
def _exchange64(i64* ptr, i64 val, i64* out) -> void { #ifdef __ARCH_X86_64__ volatile asm { movq $0, %rsi movq $2, %rdi movq $1, %rax xchgq %rax, (%rsi) movq %rax, (%rdi) } : : "r"(ptr), "r"(val), "r"(out) : "rax", "rsi", "rdi", "memory"; #endif; };
struct Pair<T> { T first, second; }; def swap<T>(T* a, T* b) -> void { T tmp = *a; *a = *b; *b = tmp; return; }; def main() -> int { Pair<int> p = {10, 20}; swap(&p.first, &p.second); // p.first == 20, p.second == 10 return 0; };
#import <standard.fx>; using standard::io::console; def main() -> int { string name = "Flux\0"; int ver = 2; // f-strings: formatted output print(f"Language: {name}\n\0"); print(f"Version: {ver}\n\0"); // i-strings: build a string value // i-strings: build a string value string msg = i"{} v{}":{name; ver}; return 0; };
Flux objects have explicit lifecycle methods. __init initializes, __exit cleans up. Use defer to schedule cleanup at scope exit — deterministic, no GC, no runtime magic.
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.