Systems Programming Language

Compiled.
Stack-first.
No compromises.

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.

hello.fx
#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;
};
LLVM
Native code backend
x86 / ARM / RISC-V
Target architectures
v2.2
Standard library
MIT
License

What Flux gives you.

01
Stack-First Allocation
Every variable is stack allocated by default. Use heap to opt into dynamic allocation explicitly. No hidden costs, no implicit constructors.
02
LLVM Backend
Flux compiles through LLVM to native machine code. You get the same optimizer that powers Clang, Rust, and Swift — targeting x86-64, ARM64, and RISC-V.
03
Inline Assembly
Drop to AT&T-style assembly inline, with full constraint lists for outputs, inputs, and clobbers. The volatile modifier prevents optimizer interference.
04
Objects & Defer
Structured types with explicit __init and __exit lifecycle methods. Use defer to schedule cleanup at scope exit — deterministic, no GC.
05
Multiple Allocators
The standard library ships arena, slab, pool, ring, and stack allocators. Choose the right memory strategy for each subsystem rather than relying on one global heap.
06
Full FFI
Import C functions with extern. Supports cdecl, stdcall, fastcall, thiscall, and vectorcall calling conventions. Name mangling control with !!.
07
Templates
Generic structs and functions with compile-time type inference. Templates are monomorphized — zero runtime overhead. Contract support for constrained generics.
08
Endianness Types
First-class be16, be32, be64, le16, le32, le64 types. Network and hardware programming without manual byte-swapping.
09
Shadow Stack
Optional shadow stack security module in the standard library. Harden return addresses against stack smashing attacks without leaving the language or the standard library.

Flux in practice.

Objects
Assembly
Templates
Strings
counter.fx
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;
};
atomic.fx
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;
};
generic.fx
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;
};
strings.fx
#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;
};

Objects & Defer

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.

  • Stack allocated by default
  • Explicit heap keyword for dynamic allocation
  • Public and private member access control
  • Trait-based interface contracts

Run Flux in your browser.

The online compiler runs real Flux programs in a sandboxed environment. No install, no setup. Share programs with a link.

Open Compiler

Linux & macOS.

01

Python 3.8+ and LLVM

Flux requires Python 3.8 or newer and LLVM with Clang. On Ubuntu and Debian, both are available via apt.

02

llvmlite Python bindings

The code generation backend uses llvmlite. Install version 0.43.0 — it matches LLVM 18 which ships with Ubuntu 24.04.

03

Clone the repository

Flux is open source. The repository includes the compiler, standard library, and examples.

04

Compile

Run fxc.py on any .fx file. The output is a native binary — no runtime required to distribute or run it.

bash
$ sudo apt install python3 python3-pip llvm clang
Reading package lists... Done
✓ Done
 
$ pip3 install llvmlite==0.43.0
Successfully installed llvmlite-0.43.0
 
$ git clone https://github.com/kvthweatt/FluxLang Flux
Cloning into 'Flux'...
✓ Done
 
$ cd Flux && python3 fxc.py examples/hello.fx
✓ Compilation completed: ./hello
 
$ ./hello
Hello, World!