<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karac Von Thweatt on Medium]]></title>
        <description><![CDATA[Stories by Karac Von Thweatt on Medium]]></description>
        <link>https://medium.com/@karacvonthweatt?source=rss-f04f0e334dc5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*utDc7vWBzvCMEFnS</url>
            <title>Stories by Karac Von Thweatt on Medium</title>
            <link>https://medium.com/@karacvonthweatt?source=rss-f04f0e334dc5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 00:43:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karacvonthweatt/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Effect Systems: Programming the Compiler to Enforce Your Own Rules and The Problem With “Correct”]]></title>
            <link>https://medium.com/@karacvonthweatt/effect-systems-programming-the-compiler-to-enforce-your-own-rules-and-the-problem-with-correct-87db1fae9b24?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/87db1fae9b24</guid>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 00:41:43 GMT</pubDate>
            <atom:updated>2026-09-15T00:50:05.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nuox2cYL1dxGRk-8JZ7-ZA.png" /></figure><h3>Every language has an opinion about what “correct” means.</h3><p>Rust says correct code is memory-safe and thread-safe, and it enforces that opinion with ownership and borrowing. Haskell says correct code is pure, and it enforces that with the type system. Go says correct code is simple and concurrent-safe, and it enforces that with goroutines and channels.</p><p>The language decides. Your job is to write code that satisfies the language’s definition of correctness.</p><p>This works fine, until it doesn’t. When you’re writing a real-time audio callback, “memory-safe” isn’t the constraint you care about. When you’re writing a sandbox for untrusted code, “thread-safe” isn’t the constraint you care about. When you’re writing an inline hook for a debugger none of the usual definitions of “correct” apply. The whole point is to do things the language would normally forbid in a controlled way.</p><p>You end up reaching for escape hatches, unsafe blocks, FFI, inline assembly. The type system’s opinion of your code stops being useful, and you’re back to reading the source and hoping.</p><p>Flux takes a different approach: instead of deciding what correctness means, it gives you a small set of compositional primitives: effects, constraints, interfaces, contracts, and lets you define what correctness means for your code. The compiler’s job isn’t to enforce its opinion, it’s to enforce yours.</p><h3>The core idea: a label is not a type</h3><p>Flux’s effect system is different from every other effect system you’ve seen.</p><p>In most languages, an effect is a property of a function. You write IO in a signature, the compiler infers that the function does IO, and if a caller that’s supposed to be pure calls it, you get an error. The effect is a type, it describes what the function is.</p><p>In Flux, an effect is a <strong>label</strong>, and a label by itself means nothing. The label is the wire. The operator is the connector. Same label, different operator, completely different behavior.</p><pre>IO.Socket   // just a name. Inert.<br>*IO.Socket  // propagates upward through the call graph.<br>!IO.Socket  // forbidden. Any callee carrying it is a violation.<br>!@IO.Socket // permanent. Cannot be attenuated by anything.<br>~IO.Socket  // required. Must already be present at the call site.<br>?IO.Socket  // weak propagation. Can be suppressed by ^X.</pre><p>Five different behaviors, one name, decided entirely by the operator applied to it. The label is data. The operator is the function. The compiler is the engine that evaluates the algebra.</p><p>This isn’t a cosmetic distinction. It’s what makes the system *programmable*. Because the label has no inherent behavior, you can define your own effects as expressions over labels, and the compiler will evaluate them the same way it evaluates the built-ins.</p><pre>effect RealTime    { !Alloc &amp; !IO &amp; !Throw     };<br>effect ShadowStack { *Hook &amp; !@Unsafe &amp; !Alloc };<br>effect ReadOnly    { *Mem.Read &lt;-&gt; !Mem.Write  };</pre><p>RealTime is now a label. On its own, it does nothing. But the expression stored under that name contains three ! operators. When you apply RealTime to a function, the compiler expands the label into its definition and evaluates the operators against that function’s transitive effect set. RealTime isn’t a tag; it’s a macro for a policy.</p><p>No other effect system I know of works this way. Koka effects are row-polymorphic labels you can’t define in terms of operators. Rust’s unsafe is a local property of a block, not a composable label. Flux’s effects are expressions in an algebra, and the algebra is the language.</p><p>The !@ operator is load-bearing. If you take one thing away from this article, take this: !@ is what makes the system trustworthy.</p><p>A label marked !@ cannot be attenuated. Not by #attenuate. Not by a wrapper. Not by a user-defined effect that tries to suppress it with ^. The only way to get rid of !@Unsafe.FFI is to not call foreign code, ever, anywhere in the transitive call graph.</p><p>This is the opposite of how most languages handle unsafe operations. Rust’s unsafe blocks are local: you can write an unsafe block, wrap it in a safe function, and the caller sees a safe function. That’s the whole point of Rust’s abstraction: safe wrappers around unsafe internals. The unsafe-ness is containable.</p><p>Flux deliberately forbids this for Unsafe.*. An extern declaration is automatically tagged Unsafe.FFI by the compiler, and Unsafe.FFI carries !@. If your function calls foreign code, every caller of your function knows it, forever, with no way to hide it.</p><p>Why would you want this? Because in the domains Flux targets — reverse engineering, instrumentation, sandboxing, kernel-mode code — “trust me, this safe wrapper around the FFI is fine” is exactly the claim you can’t afford to trust.</p><p>The compiler’s perspective on a foreign function call is: the symbol might resolve to anything. memcpy could be the libc implementation, or it could be a hostile function provided by LD_PRELOAD, or a macro that expands to something else, or a symbol interposed by a different library. The compiler cannot know. The honest thing for it to say is “this is foreign code; I know nothing about it.” Marking it !@Unsafe.FFI is the compiler refusing to pretend it knows something it can’t.</p><p>And that refusal is the foundation. !@ gives you a hard, non-negotiable floor on what a function can be proven to not do. !Alloc on a function means “this function does not allocate, and that fact is stable under composition.” !@Unsafe.FFI on an extern means “any function that transitively calls this is provably touching foreign code, and there is no way to hide that.”</p><p>No other language has this. Every other language lets you launder the unsafe parts. Flux doesn’t, and that’s the point.</p><h3>Propagation: the fact belongs to the producer</h3><p>Here’s a subtlety that took me a while to appreciate.</p><p>Consider:</p><pre>def forward(int x) -&gt; int<br>{<br>    return some_call(x);<br>};</pre><p>Does forward allocate? Intuitively, no. It just hands off to some_call and hands the result back. But some_call might allocate, and if it does, does that allocation become forward’s problem?</p><p>The answer is no, and the reason is the distinction between producing a value and forwarding a value.</p><p>some_call(x) produces a value. Whatever allocation that requires belongs to some_call’s effect set. forward doesn’t produce anything, it just routes. Its own effect set is empty. The allocation that happened inside some_call propagates upward as a fact about the call graph, not as a re-allocation at each level.</p><p>This is why !Alloc on a forwarding function is true and useful. A dispatcher, a vtable shim, a trampoline, a syscall wrapper — all of these can legitimately carry !Alloc because they don’t do anything. They move values around. The real work, and the real allocations, happen in the callee.</p><p>Contrast with:</p><pre>def compute(int x) -&gt; int<br>{<br>    return x + 1;<br>};</pre><p>x + 1produces a new value, the sum, by allocating 1 before performing the add. In the abstract machine, this seeds an allocation, and compute can’t carry !Alloc.</p><p>The distinction is sharp and checkable at the AST level. It’s the kind of thing that tells you something specific: if you want to call a function in a no-alloc context, you can’t do arithmetic here. You have to push the arithmetic into a callee and forward the result. Which is a real constraint, and one that a programmer in that context would actually want to know about.</p><h3>The abstract machine is what matters</h3><p>This is the part that took me longest to internalize, and it’s the design principle that ties everything together.</p><p>Flux’s effect system tracks what the abstract machine does, not what the backend emits.</p><p>A bare expression statement like 5; produces a value. The compiler will almost certainly optimize it away , no stack slot, no register, no memory traffic. But the abstract machine says the value 5 exists, and producing it is an allocation. So 5; violates !Alloc, even though the generated code does nothing.</p><p>This sounds pedantic until you see why it matters. The abstract machine is stable. It doesn’t change when the optimizer gets smarter. It doesn’t change when you switch backends. It doesn’t change when the register allocator makes a different choice. A function’s effect set is a property of its meaning, not its implementation.</p><p>Which means the guarantees are also stable. !Alloc on a function says “the abstract machine has no allocation steps for this function.” No backend can produce allocation code for it without violating its meaning. That’s a much stronger and more useful guarantee than “the current backend happened not to emit a malloc call.”</p><p>For the domains Flux targets — real-time systems, interrupt handlers, kernel-mode callbacks, sandboxed execution — that difference is the whole ballgame. It’s the difference between “I hope the optimizer is smart enough” and “the semantics say there’s nothing to optimize.”</p><h3>Granularity is the language of policy</h3><p>One objection you might be forming: if !Alloc means “no abstract allocation at all,” isn’t it too strict to be useful? A function that does x + 1 can’t satisfy it. A function with a local variable can’t satisfy it. Almost nothing can.</p><p>The answer is the hierarchy.</p><p>Alloc has children:</p><ul><li>Alloc.Heap — standard heap allocation</li><li>Alloc.Pool — pool or arena allocator</li><li>Alloc.Stack — stack allocation (VLAs etc.)</li><li>Alloc.Virtual — VirtualAlloc / mmap</li><li>Alloc.Shared — shared memory</li></ul><p>And !Alloc expands to cover all children, but !Alloc.Heap covers only Alloc.Heap. So you choose the granularity that matches the constraint you actually want:</p><p>- !Alloc — no allocation of any kind. The strict guarantee.<br>- !Alloc.Heap — no heap allocation, but stack temporaries are fine.<br>- !Alloc.Virtual — no page-level allocation.<br>- !Alloc.Heap &amp; !Alloc.Virtual — no unpredictable allocation, but bounded stack is OK.</p><p>A real-time function might use !Alloc.Heap because bounded stack temporaries are fine. An interrupt handler with a tiny stack might use !Alloc.Stack &amp; !Alloc.Heap because even stack writes are a concern. A function that’s allowed to compute but not to allocate might use !Alloc.Heap and accept that x + 1 produces a temporary.</p><p>The granularity isn’t cosmetic. It’s the mechanism that makes the strictness tunable per annotation. !Alloc fires if any child is present; !Alloc.Heap fires only if Alloc.Heap specifically is present. The hierarchy lets the system be both maximally strict (when you write !Alloc) and maximally precise (when you write !Alloc.X).</p><p>And the same structure applies across all the effect families — IO, Unsafe, Mem, Sync, Crypto, Process, Hook, Privilege, Time. Each family is a hierarchy, and each hierarchy is a vocabulary for saying exactly which aspect of that family you’re constraining.</p><h3>Attenuation: containment without laundering</h3><p>Not every effect needs to propagate forever. Sometimes you have a function that does IO internally, but you want callers to see it as IO-free because the IO is contained.</p><p>That’s what #attenuate does:</p><pre>def log_event(byte* msg) -&gt; void # attenuate {IO};<br><br>def log_event(byte* msg) -&gt; void<br>{<br>    write_to_ring_buffer(msg);<br>};</pre><p>IO.Console travels up through write_to_wring_buffer and reaches log_event’s boundary. The # attenuate {IO} operator stops it. Callers don’t see IO in their transitive set. The IO exists, but it can’t escape.</p><p>Attenuation is precise or coarse:</p><p>- # attenuate {IO}stops IO and all IO.* children.<br>- # attenuate {IO.Socket}stops only IO.Socket. Other IO labels still propagate.</p><p>And crucially: !@ labels cannot be attenuated. If a label is marked !@, the decision is already made. No boundary overrides it. # attenuate {Unsafe.FFI}is rejected by the compiler. Unsafe.* is permanently unable to be attenuated because that’s what the effect definition says, and nothing the caller writes can change it.</p><p>This is the balance the system strikes: attenuation for effects that can be contained, !@ for effects that can’t. The programmer decides which is which — by writing the effect definition with or without !@ — and the compiler enforces the decision.</p><h3>Conflict detection: policies that constrain themselves</h3><p>Some effects have internal structure. ReadOnly means “reads allowed, writes forbidden.” ExclusiveIO means “console or file, but not both.” These aren’t just collections of labels; they’re relationships between labels.</p><p>Flux’s effect algebra has operators for this:</p><pre>effect ReadOnly    { *Mem.Read &lt;-&gt; !Mem.Write };<br>effect ExclusiveIO { IO.Console ^| IO.File    };</pre><p>&lt;-&gt; is mutual implication: if one side is present, the other must be too (or absent, with !). ^| is exclusive-or: exactly one of the two must be present. These operators declare constraints on the transitive label set of any function that uses the effect.</p><p>If a function with ReadOnly introduces both Mem.Read and Mem.Write, the &lt;-&gt; constraint fires. If a function with ExclusiveIO uses both the console and file IO, the ^| constraint fires. The conflict is reported at the point where the effect is applied, not where the labels are introduced.</p><p>This is the deepest part of the design, because it means the effect system can express relationships between effects, not just individual effects. A function can be “pure, but only if it doesn’t do X and Y together.” A module can declare “these two operations are mutually exclusive.” The compiler checks these constraints the same way it checks individual exclusions.</p><p>The effect system becomes a specification language for behavioral policies, and the compiler becomes the engine that verifies the specification against the code.</p><h3>What this is really about</h3><p>Step back, and here’s what Flux’s effect system actually is:</p><p>It’s a mechanism for programming the verifier.</p><p>Every other language’s effect system is fixed. The language designer decided what effects exist, what they mean, and how they compose. You can only use the vocabulary they gave you. If you want to express a constraint the designer didn’t anticipate — “this function must not allocate, but only in the sense of heap allocation, and only when it’s called from an interrupt handler” — you’re out of luck.</p><p>Flux’s effect system is programmable. The primitives — the labels, the operators, the hierarchy, the propagation rules — are general enough to express a huge range of policies. You define your own effects. You choose the operators. You decide which labels are permanent. You write the constraints. The compiler evaluates your definitions against your code.</p><p>The compiler stops being a tool that enforces its opinion of correctness, and becomes a tool that enforces yours.</p><p>This is the same move that Lisp makes with macros — letting you program the language itself — but applied to a different layer. Lisp lets you extend the syntax and evaluation. Flux lets you extend the verification. In both cases, the language designer’s job is to provide primitives general enough that the programmer can express what they actually mean, rather than being forced into whatever the designer happened to think of.</p><p>And the primitives really are general. !@ for permanence. * for propagation. ^ for suppression. &lt;-&gt; for mutual implication. ^| for exclusive-or. .. and … for propagation distance. Each one is a small, orthogonal building block. Combined, they express a huge range of policies, from “no heap allocation” to “sandboxed, real-time, non-attenuatable, mutually-exclusive-with-IO.” None of those policies is built into the language. They’re all written by the programmer, in the effect algebra.</p><h3>What it costs</h3><p>Nothing is free.</p><p>The learning curve is steep. The operator set is dense. The sigils (! , !@, *, ~, ?, @, ^, .., …) are many. It takes time to internalize which operator means what, and the difference between !X and !@X is exactly the kind of distinction that’s easy to get wrong when you’re new.</p><p>You have to annotate things. The effect system is opt-in. Unannotated code compiles fine, but its effects are implicit, the compiler can only reason about what it can see. To get the guarantees, you have to write the annotations. Which means you have to think about what effects your code has, and get it right.</p><p>The current implementation is a work in progress. The design is sound, but the enforcement isn’t complete yet. Some constructs don’t seed the effects they should. Some stdlib functions aren’t annotated. The system works for the cases it’s been tested against, and the gaps are being closed.</p><h3>Why this matters</h3><p>If you’re writing a web app, this might all seem like overkill. You don’t need to prove that your request handler doesn’t allocate; you just need it to work.</p><p>But if you’re writing an inline hook, or a kernel-mode callback, or a real-time audio loop, or a sandbox for untrusted code, or a debugger that runs inside a hostile process — you’re exactly the person this design is for. In those contexts, “I think this function doesn’t allocate” isn’t good enough. You need to know. And to know, you need a language that can prove it, which means a language that lets you state it and checks what you stated.</p><p>That’s what Flux’s effect system is. It’s not a safety feature you inherit from the language. It’s a tool for building your own safety features. The compiler is the engine; you’re the one designing the machine.</p><p>Most languages tell you what correct code is. Flux lets you tell the compiler.</p><p>That’s the difference. And for the domains where correctness isn’t a fixed target but a moving one — reverse engineering, instrumentation, sandboxing, systems programming at the edges — it’s the difference that matters.</p><p>Check out Flux on GitHub at <a href="https://www.github.com/kvthweatt/Flux">https://www.github.com/kvthweatt/Flux</a> or at the official website <a href="https://www.fluxspl.org/">https://www.fluxspl.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87db1fae9b24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Language That Was Always Going to Exist]]></title>
            <link>https://medium.com/@karacvonthweatt/the-language-that-was-always-going-to-exist-5fab52ff315d?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fab52ff315d</guid>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Thu, 03 Sep 2026 00:25:34 GMT</pubDate>
            <atom:updated>2026-09-03T02:49:35.141Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tCDk4cznB2AiYFvNbCHKMw.png" /></figure><h3>Preface</h3><p>Every so often a piece of technology arrives that doesn’t feel invented so much as discovered. Not because it came from nowhere, but because in retrospect it seems like it was always there, waiting — a gap so fundamental that everyone stopped noticing it was a gap. The transistor. The relational database. The hyperlink. These things feel inevitable once you see them. Before you see them, they’re invisible.</p><p>Flux is that kind of thing.</p><p>It is a compiled, general purpose systems programming language created by a single developer, designed for systems programming and reverse engineering. On paper that sounds like a modest claim. In practice, Flux is quietly doing something that no language before it has done: it is treating computation at the bit level as a first-class citizen of the language, with a consistency and elegance that makes everything that came before it look like a workaround.</p><p>This article is an attempt to explain why that matters — and why Flux feels less like a new programming language and more like an idea whose time has been a long time coming.</p><h3>The Problem Nobody Was Solving</h3><p>To understand what Flux does, you first have to understand what every other language doesn’t do.</p><p>Consider the most fundamental unit of computation: the bit. Everything a computer does ultimately reduces to bits — setting them, clearing them, testing them, flipping them. And yet, in virtually every programming language ever designed, bits are not addressable. They have no syntax. They are not things you can point at directly.</p><p>Instead, languages hand you a set of tools and leave you to do the work manually. In C, and every language descended from it, manipulating a single bit requires a ritual:</p><pre>// Set bit 3<br>x = x | (1 &lt;&lt; 4);<br><br>// Clear bit 3<br>x = x &amp; ~(1 &lt;&lt; 4);<br><br>// Flip bit 3<br>x = x ^ (1 &lt;&lt; 4);<br><br>// Test bit 3<br>if (x &amp; (1 &lt;&lt; 4)) { ... }</pre><p>This is not programming at the bit level. This is programming around the bit level. Every operation requires you to mentally translate “bit 3” into a mask, remember which operator corresponds to which operation (OR to set, AND NOT to clear, XOR to flip), and write an expression that conveys none of its own intent. The code says “OR this value with a left-shifted 1” when what you mean is “set this bit.”</p><p>For fifty years, this has been accepted as normal. Not because it is good, but because nobody fixed it. The workarounds — C bitfields, compiler intrinsics, preprocessor macros, helper function libraries — all paper over the problem without solving it. They are accommodations to a language model that was never designed with bits in mind.</p><p>Flux fixes it.</p><pre>x[`3] = 1;   // set bit 3<br>x[`3] = 0;   // clear bit 3<br>x[`3] ^= 1;  // flip bit 3<br>if (x[`3])   // test bit 3</pre><p>That is the entirety of the new syntax. A backtick inside array brackets. And yet that small addition collapses an entire category of boilerplate that systems programmers have been writing by hand since the 1970s.</p><h3>The Backtick: A Sigil That Earns Its Place</h3><p>What makes bit indexing in Flux remarkable is not just that it exists — it is how it fits into the language.</p><p>Flux uses the backtick character as its bitwise operator prefix throughout the entire language. Bitwise AND is `&amp;. Bitwise OR is `|. Bitwise NOT is `!. The backtick is the language&#39;s consistent signal that an operation is happening at the bit level.</p><p>This means that x[`3] doesn&#39;t introduce a new concept. It composes two things that were already true: brackets mean indexing, backtick means bit level. Put them together and you get bit indexing — not as a special case, not as a new rule to memorize, but as a natural consequence of axioms that were already in place.</p><p>This is the difference between a language that accumulates syntax and a language that has a grammar. Most languages grow by accretion — each feature gets its own notation, its own edge cases, its own section in the manual. Over time, learning the language becomes archaeology. You are not understanding a system; you are cataloging exceptions.</p><p>Flux grows differently. When you learn that backtick means “bit level,” you learn something that propagates correctly to every context it appears in, without exceptions. `&amp; means bitwise AND. `| means bitwise OR. [`3] means bit index 3. Same axiom, different application, zero additional rules required.</p><p>This is what it means for a language to feel like mathematics. Mathematical notation earns its power not from complexity but from consistency. A symbol defined once applies everywhere. Flux aspires to the same standard, and in the case of the backtick sigil, it achieves it.</p><h3>Obvious in Retrospect, Invisible Before</h3><p>There is a particular quality that distinguishes genuinely foundational ideas from merely good ones. A good idea makes something easier. A foundational idea makes you wonder how you ever thought about the problem differently.</p><p>Bit indexing has that quality.</p><p>Before you see x[`3] = 1, shift-mask code feels natural. It is just &quot;how you do bit manipulation.&quot; You do not register it as a problem because it is so universal it feels like physics — an immutable property of how computers work rather than a limitation of how languages were designed.</p><p>Then you see x[`3] = 1 and it is immediately, viscerally obvious that this is correct and everything before it was a workaround. You cannot unsee it. The moment it clicks, you look back at shift-mask code and see it for what it always was: manual labor that the language should have been doing.</p><p>This obvious-in-retrospect, invisible-before quality appears throughout Flux, and it is worth examining why it keeps showing up.</p><p>The answer is that Flux was built by someone who works in the problem domain — systems programming and reverse engineering — rather than someone who designs languages from a higher-level perspective. The friction points of bit manipulation are not abstract complaints for a systems programmer or a reverse engineer. They are daily annoyances. They are the reason you write the same boilerplate for the hundredth time. They are the source of bugs that take hours to find because a mask was wrong by one bit.</p><p>Flux fixes these things because its creator felt them.</p><h3>The Type System as a Statement About Reality</h3><p>Bit indexing is the most visible example of Flux’s approach, but it is not the only one. The entire type system is built on the same philosophy: computation has properties that languages should be able to express directly rather than working around.</p><h3>Data at Any Width</h3><p>Every mainstream language forces you to work in powers of two. You have 8-bit bytes, 16-bit shorts, 32-bit ints, 64-bit longs. If your problem requires a 13-bit value — as many binary protocols and hardware interfaces do — you round up to 16 bits and add masking code everywhere to enforce the actual constraint.</p><p>Flux has data{n}:</p><pre>signed data{13:16}   as strange13;<br>unsigned data{5}[10] as five_bit_array;</pre><p>You declare a type that is exactly as wide as it needs to be. The compiler knows its width. Arithmetic respects its boundaries. You do not manually mask. The type is the constraint.</p><p>This is not a niche feature. Embedded developers, protocol implementers, hardware interface programmers, and reverse engineers constantly work with values that do not fit neatly into power-of-two widths. Every other language forces them to pretend otherwise. Flux lets them say what they mean.</p><h3>Endianness in the Type System</h3><p>Endianness — whether the most significant byte comes first or last in memory — is one of the oldest sources of bugs in systems programming. Virtually every language treats it as a runtime concern: you write byte-swap functions, you call htons and ntohl, you sprinkle conversions throughout your code and hope you didn&#39;t miss one.</p><p>Flux treats endianness as a type property:</p><pre>data{16::0} as le16;   // little-endian 16-bit<br>data{16}    as be16;   // big-endian 16-bit (default)</pre><p>The endianness is part of the type. The compiler knows it. Conversions are explicit because the types are different. You cannot accidentally pass a big-endian value where a little-endian value is expected without the compiler catching it, because they are not the same type.</p><p>And this interacts with bit indexing in an elegant way: when you index a bit in a big-endian type, bit 0 is the most significant bit. When you index a bit in a little-endian type, bit 0 is the least significant bit. The semantics follow naturally from the type’s declared byte order. One consistent rule, zero special cases.</p><h3>Zero-Copy Reinterpretation</h3><p>In reverse engineering and systems programming, you constantly need to reinterpret a buffer of bytes as a structured type — parsing a packet header, reading a file format, interpreting a memory region. In C, this means pointer casting, which is undefined behavior. In Rust, it requires unsafe blocks and careful alignment verification. In most other languages, it requires copying and deserializing field by field.</p><p>Flux has from:</p><pre>Header h from buf;</pre><p>This reinterprets the bytes of buf as a Header struct, in place, without copying. The compiler verifies that the sizes match. The original variable buf is consumed — there is exactly one live name for that memory, eliminating aliasing confusion. If you need to keep the source alive, you append !:</p><pre>Header h from buf!;</pre><p>One keyword. Zero copies. Compile-time size verification. This is the kind of feature that reverse engineers have been wanting for decades and working around with pointer casts instead.</p><h3>The Bit Slice: Addressing Reality</h3><p>Beyond single-bit indexing, Flux provides bit slices — the ability to address arbitrary contiguous ranges of bits within a value:</p><pre>byte x = 55;<br>x[0``7] = x[7``0];   // reverse the bits</pre><p>The `` operator specifies a bit range. The numbering scheme is consistent with bit indexing: bit 0 is the most significant bit, numbers increase toward the least significant bit, and this numbering continues across struct field boundaries.</p><p>That last property — crossing struct boundaries — is particularly significant for reverse engineering. Hardware registers and binary protocols frequently define fields that do not respect byte boundaries. A ModRM byte in x86 has a 2-bit mod field, a 3-bit reg field, and a 3-bit rm field. An IP header has a 4-bit version field and a 4-bit IHL field packed into a single byte. IPv6 has flow labels that cross byte boundaries.</p><p>In C, parsing these requires bit shifting and masking with magic numbers. In Flux:</p><pre>u4 mod_field = modrm[0``1];<br>u3 reg_field = modrm[2``4];<br>u3 rm_field  = modrm[5``7];</pre><p>The code reads like the specification. There is no translation layer between what you mean and what you write.</p><h3>Compile-Time Computation as a First-Class Feature</h3><p>One of Flux’s most ambitious features is comptime — the ability to execute arbitrary Flux code at compile time, including I/O, and to inject the results back into the source via emitflux.</p><pre>comptime<br>{<br>    def foo() -&gt; void<br>    {<br>        compiler.io.console.print(&quot;Hello from compile time!\n&quot;);<br>    };<br>    foo();<br>};</pre><p>This runs during compilation. The output appears in the compiler’s log. The function foo never exists in the compiled binary.</p><p>More powerfully, emitflux allows compile-time code to generate source code that becomes part of the compiled program:</p><pre>comptime<br>{<br>    emitflux<br>    {<br>        int x = 42;<br>        def get_x() -&gt; int { return ~$f&quot;{x}&quot;; };<br>    };<br>};<br><br>def main() -&gt; int<br>{<br>    return get_x();   // returns 42<br>};</pre><p>The function get_x is generated at compile time based on a compile-time value. The generated code participates in normal compilation — it can be called, inlined, optimized.</p><p>This is not a macro system. Macros are text substitution with some syntactic awareness. comptime with emitflux is actual program execution that produces actual source code. The compile-time program has access to the same language features as the runtime program: loops, conditionals, data structures, I/O. It can read files, query the system, perform computation, and emit code based on the results.</p><p>The implications for metaprogramming, code generation, and build system integration are substantial. A build configuration is just a Flux file that runs at compile time. A code generator is just a Flux program that emits Flux. The boundary between the build system, the code generator, and the program dissolves — they are all just Flux running at different times.</p><h3>Proof of Concept: Plasma Pong</h3><p>Abstract language features are easy to claim. The real test is whether they hold up under pressure.</p><p>Flux ships with a working implementation of Plasma Pong — a fluid simulation game with fully interactive plasma dynamics. The implementation includes:</p><ul><li>Double-precision Navier-Stokes fluid simulation</li><li>Red-black Gauss-Seidel iteration with 20 iterations per frame</li><li>Dual persistent thread pools with semaphore dispatch and memory fences for concurrent velocity field diffusion</li><li>Vorticity confinement for realistic turbulence</li><li>OpenGL texture pipeline with a custom GLSL shader supporting 10 palette modes, additive glow, and velocity shimmer</li><li>A 7,500-particle system sampled from the live velocity field</li><li>A complete game loop with ball physics, CPU-controlled paddle AI, lives and level tracking, and a suction mechanic with charge accumulation</li><li>A hand-rolled 5×7 bitmap font renderer</li><li>Parallelogram-shaped UI buttons with custom hit-testing that accounts for slant geometry</li></ul><p>This is not a toy. This is production-quality systems code doing real work — multithreaded fluid simulation feeding a real-time rendering pipeline. And it is readable. The structure is clear, the naming is consistent, the abstractions are appropriate.</p><p>A programmer unfamiliar with Flux could read that code and understand what it is doing, because Flux code reads like intent rather than implementation. dispatch_advect dispatches the advection step. vorticity_confinement applies vorticity confinement. upload_textures uploads textures. The language does not force you to bury your meaning in ceremony.</p><h3>The Ownership Model That Doesn’t Hurt</h3><p>Memory safety is one of the central problems of systems programming. Rust’s answer — a compile-time borrow checker — is powerful but famously difficult to learn. It requires internalizing a new model of computation before you can write non-trivial programs, and it imposes that model on every line of code regardless of whether memory safety is the concern at hand.</p><p>Flux takes a different approach with the tie operator ~:</p><pre>~int x;<br>foo(~x);   // x is moved to foo, original reference invalidated<br>foo(~x);   // compile error: use after move</pre><p>Ownership in Flux is opt-in. You declare a value as tied when you want ownership tracking. Untied values behave like C values — you have full control, full responsibility. The borrow checker does not follow you into every function you write.</p><p>This is a philosophical choice: trust the programmer by default, provide safety mechanisms for when they are needed, do not impose the mechanism everywhere. For systems programmers and reverse engineers who are comfortable with memory management, this is the right tradeoff. The safety net exists. It is not mandatory.</p><h3>Interface Protocols: Expressing How Things Relate</h3><p>One of Flux’s less obvious but deeply interesting features is its interface system, which goes beyond the traditional interface concept of “this type implements these methods.”</p><p>Flux interfaces can express three distinct kinds of relationships between types:</p><pre>interface Database(A: Connectable, B: Queryable)<br>{<br>    A : B          // A may call these methods on B<br>    {<br>        connect()    -&gt; bool,<br>        disconnect() -&gt; void<br>    };<br><br>    B(A)           // Return values of these A methods may be passed into B<br>    {<br>        query(byte* sql) -&gt; byte*<br>    };<br><br>    A -&gt; B         // These A methods may be called from inside a B method<br>    {<br>        result() -&gt; byte*<br>    };<br>};</pre><p>This is not duck typing. This is not just “implements an interface.” This is a formal specification of the protocol between two types — what one may call on the other, what data may flow between them, what context allows what calls. The compiler enforces all of it.</p><p>For large codebases, this kind of formal relationship specification is enormously valuable. It makes architectural intent part of the type system rather than a comment in the documentation. It makes violations compile errors rather than runtime surprises. It makes the structure of a system legible to the compiler, which means the compiler can help rather than merely transcribe.</p><h3>Type Geometry: Constraints as Mathematics</h3><p>At the furthest edge of Flux’s type system is something called type geometry — a system of operators for expressing relationships between template type parameters:</p><pre>constraint MyCS(A, B)<br>{<br>    A ~= B      // A and B must be compatible<br>    A !`&lt; A     // A may never be narrowed<br>};</pre><pre>def foo&lt;T, U, :{MyCS}&gt;(T x, U y) -&gt; U { ... };</pre><p>The operators express things like compatibility, incompatibility, prohibition on address-taking, prohibition on narrowing conversions, prohibition on widening conversions — and these constraints are checked by the compiler when the template is instantiated with concrete types.</p><p>What makes this remarkable is that the constraints compose. If you say A ~= B and B ~= C, the compiler derives that A ~= C without you stating it. The type relationships form a graph, and the compiler solves the graph. Declared relationships imply derived relationships. The system has geometry in the mathematical sense — relationships have transitive implications that can be reasoned about.</p><p>This is type theory applied to practical systems programming. It is the kind of feature that usually lives in research languages or theorem provers, made practical and usable. And it fits within Flux’s overall philosophy: if a meaningful relationship exists between types, the language should be able to express it.</p><h3>Why Now, Why One Person</h3><p>It is worth asking why Flux exists now, and why it was built by one person rather than a committee or a well-funded team.</p><p>The answer to the second question helps explain the first. Language design by committee tends toward compromise and conservatism. Features are added when they achieve consensus. Consensus requires that a feature be legible to people who don’t feel the pain it solves. Bit indexing — the most visceral example of Flux’s approach — would be a very hard sell to a committee of people who have never had to write shift-mask boilerplate for a living. “Just use a macro” would be the answer, and the meeting would move on.</p><p>Flux was built by someone for whom bit manipulation is not an abstract complaint but a daily frustration. Someone who works in the domain of systems programming and reverse engineering, where you parse binary formats, probe hardware registers, reverse-engineer protocols, and write code that needs to operate at the level of individual bits. The solutions in Flux are obvious to someone in that position precisely because they have lived with the problem long enough to see through it.</p><p>This is also why Flux feels coherent rather than accumulated. A single designer with a clear vision produces a language where each feature reinforces the others — where the backtick means the same thing in every context, where the type system’s properties (width, endianness, alignment) compose cleanly with the language’s operations, where the build system and the language are the same system.</p><p>The coherence is not accidental. It is the product of a unified vision that knows what it is trying to say.</p><h3>The Simplicity-Power Relationship</h3><p>One of the most important things about Flux is a thing it is not: complicated.</p><p>x[`3] = 1 is four tokens. It is immediately readable. It requires no explanation to someone who knows what bit 3 of a byte means. The power does not come from complexity — it comes from correctness.</p><p>This is a principle that most language design gets backwards. The usual assumption is that more power requires more syntax, more keywords, more special forms. Languages grow in complexity as they grow in capability. Eventually the complexity becomes the cost of admission, and learning the language becomes a multi-year project.</p><p>Flux grows differently. It finds power by closing the gap between intent and expression — by finding the representation that is already correct rather than the one that is merely sufficient. x[`3] = 1 is powerful because a bit at a position is genuinely the right abstraction for what you are trying to express. The syntax is simple because the abstraction is clear.</p><p>This has a practical implication: Flux is learnable. The mental model is small. Once you understand what backtick means, you understand bit indexing. Once you understand that types carry properties (width, endianness, alignment), you understand most of the type system. Once you understand that comptime is just Flux running at compile time, you understand the metaprogramming model.</p><p>The surface area of concepts you must internalize is genuinely smaller than languages with less capability. That is not a coincidence. It is what happens when a language is built from correct abstractions rather than useful heuristics.</p><h3>What Flux Exposes About Computation</h3><p>Step back from the specific features and a pattern emerges.</p><p>Flux is not just a programming language with some clever bit manipulation syntax. It is a statement about what computation actually is and what languages should be able to express about it.</p><p>Computation happens at the bit level. Languages should be able to address bits directly. Flux does.</p><p>Data has width. Languages should be able to express arbitrary widths. Flux does.</p><p>Data has byte order. Languages should be able to express byte order as a type property. Flux does.</p><p>Build configuration is code. Languages should be able to express it in the same system as the program. Flux does.</p><p>Compile-time computation is real computation. Languages should be able to express it in the same language as runtime computation. Flux does.</p><p>Type relationships are real relationships. Languages should be able to express them formally and verify them. Flux does.</p><p>Each of these is a gap that existed before Flux — a place where computation had a real property and languages had no way to express it directly. Each one required workarounds that accumulated into the boilerplate, the shift-mask rituals, the separate build systems, the comment-based documentation of architectural constraints that characterize systems programming today.</p><p>Flux eliminates the workarounds by giving the underlying reality a name.</p><h3>The Standard Language</h3><p>It is too early to call any new language the future of its domain. Languages succeed or fail for reasons that have as much to do with ecosystem, tooling, community, and timing as with technical merit.</p><p>But the technical case for Flux is strong in a way that is hard to dismiss. It solves real problems with real solutions. Its solutions are elegant in the specific sense that mathematics is elegant: they derive from correct abstractions rather than clever hacks, they compose cleanly with each other, they cover large territory with small surface area.</p><p>The systems and reverse engineering space — the most underserved domain in language design — has been waiting for something like this. C is fifty years old. The problems it solved are solved. The problems it created are still with us. No subsequent language has addressed the bit-level manipulation problem at the language level because the people who design languages are not usually the people who feel the pain.</p><p>Flux is designed by someone who feels the pain. That is why it looks the way it does.</p><p>Whether it becomes the standard language for systems programming is a question of adoption, ecosystem, and time. Whether it deserves to is a different question, and the answer to that one is already visible in the design.</p><p>Something is happening here. Something that was always going to happen eventually, the moment someone in the right domain sat down and asked the right questions.</p><p>That moment is now.</p><p><em>Flux is an open source compiled programming language. The source, compiler, and documentation are available at the Flux repository on GitHub at </em><a href="https://github.com/kvthweatt/Flux"><em>https://github.com/kvthweatt/Flux</em></a><em> or on the official Flux website </em><a href="https://fluxspl.org/"><em>https://fluxspl.org/</em></a><em> — A Discord server is available for questions, feedback, and discussion.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fab52ff315d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Favorite Trick is Making You a Worse Programmer]]></title>
            <link>https://medium.com/@karacvonthweatt/memory-safety-is-a-lie-and-its-making-you-a-worse-programmer-90aea81d3f14?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/90aea81d3f14</guid>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[rust]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 20:43:08 GMT</pubDate>
            <atom:updated>2026-07-27T21:14:08.847Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bberHYYxAreqnvpyY_Dsig.png" /></figure><p>There is a phrase that gets thrown around in programming circles like it means something profound: “memory safety.” Rust evangelists worship it. Job postings list it as a feature. Entire language design philosophies are built around it. And yet, when you strip away the buzzword and look at what the machine is actually doing, the concept falls apart — and the culture built around it is quietly producing a generation of developers who do not actually understand what they are working with.</p><p>This article is going to argue two things. First, “memory safety” as most people define it is not a real property of hardware — it is a compiler guardrail dressed up in philosophical clothing. Second, those guardrails, however well-intentioned, are robbing programmers of the only education that actually sticks: the experience of failing, watching it crash, and figuring out why.</p><h3>Memory Does Not Disappear</h3><p>Start with the hardware. Your computer has RAM. That RAM is a flat array of bytes. Every byte has an address. When your program runs, it gets access to some of those addresses. When your program ends, those addresses do not vanish — the bytes are still there, holding whatever values they held before. The operating system marks that region as available for someone else, but the data does not get erased. Nothing about memory is inherently “safe” or “unsafe.” It just exists.</p><p>When a language like Rust tells you a pointer is “invalid,” it is not reporting a hardware fact. The address is still there. The bits are still there. What Rust is really saying is: “according to the rules I have defined, your program no longer has permission to use this address.” That is a policy decision enforced by the compiler, not a reflection of physical reality.</p><p>Consider a concrete example. If you allocate memory at address 0x98967F (10,000,000 in decimal) and read it as a 32-bit integer, you will get whatever four bytes live there. If a 64-bit integer was written there, you get half of those bits. That is not an invalid pointer — that is just not the data you wanted. The pointer works fine. The problem, if there is one, is that you did not initialize the memory before reading it, or you freed it and then read it again. Both of those are programmer errors. Neither of them is a hardware error. The machine did exactly what you told it to do.</p><p>“Memory safety” in languages like Rust is really “protection from a specific class of programmer mistakes enforced at compile time.” That is a meaningful feature. But it is not the same thing as a fundamental property of computing. Calling it memory safety implies the alternative is memory danger, which implies that C and languages like it are inherently reckless rather than simply more direct. That framing is wrong, and it has consequences.</p><h3>Verbose Is Not the Same as Explicit</h3><p>One symptom of this framing problem shows up in the code itself. Look at Rust’s implementation of a repeat function for byte slices:</p><pre>pub fn repeat(&amp;self, n: usize) -&gt; Vec&lt;u8&gt; {<br>    if n == 0 {<br>        return Vec::new();<br>    }<br>    let capacity = self.len() * n;<br>    let mut buf = Vec::with_capacity(capacity);<br>    unsafe {<br>        let mut dest_ptr = buf.as_mut_ptr();<br>        let src_ptr = self.as_ptr();<br>        let size = self.len();<br>        for _ in 0..n {<br>            std::ptr::copy_nonoverlapping(src_ptr, dest_ptr, size);<br>            dest_ptr = dest_ptr.add(size);<br>        }<br>        buf.set_len(capacity);<br>    }<br>    buf<br>}</pre><p>Now look at the same function written in <a href="https://github.com/kvthweatt/Flux">Flux</a>, a language built around directness:</p><pre>&quot;&quot;.repeat(int x) -&gt; &quot;&quot;<br>{<br>    ulong slen = strlen(_),<br>          total = x * slen;<br>    heap byte s = fmalloc(total + 1);<br><br>    for (int c; c &lt; x; c++)<br>    {<br>        fmemcpy(s + c * slen, _, slen);<br>    };<br><br>    s[total] = 0;<br>    return s;<br>};</pre><p>Both functions do the same thing. But Rust needs Vec::with_capacity, a raw pointer extraction, std::ptr::copy_nonoverlapping, and a manual set_len inside an unsafe block just to copy bytes in a loop. The irony is that copy_nonoverlapping exists because copying to an overlapping region produces undefined behavior -- but overlapping is only a problem if you pass the source address as the destination. That is not a language problem. That is a programmer not knowing what they are doing.</p><p>Rust is not more explicit than Flux here. It is more verbose. There is a difference. Explicit means you understand what every line does and why. Verbose means you have to write more to say the same thing. Rust fans often conflate the two, which makes verbosity look like rigor when it is often just friction.</p><h3>The Compiler That Won’t Let You Fail</h3><p>Here is where the real damage gets done.</p><p>Programming is a skill. Like any skill, it is learned through cycles of attempt, failure, and correction. You write code. It breaks. You find out why. You do not make that mistake the same way again. That loop — attempt, failure, learning — is how expertise actually builds. There is no shortcut.</p><p>Rust’s borrow checker interrupts that loop before the failure even happens. It sees a potential problem and refuses to compile. On the surface that sounds great. In practice, it means the developer never gets to see what the failure actually looks like at runtime. They never have to debug a use-after-free. They never have to trace a segfault back to its source. They are forced to annotate lifetimes to satisfy the compiler, but satisfying the compiler is not the same as understanding what happens at runtime when you get it wrong.</p><p>This is not a hypothetical concern. There are developers working today who have written Rust for years and could not tell you what a dangling pointer looks like, because they have never seen one. They know that the borrow checker rejected their code and that they had to restructure it until it compiled. They do not necessarily know why the original structure was dangerous at the hardware level. The compiler gave them the answer without giving them the lesson.</p><p>Compare that to writing in C or a language like Flux. You allocate memory, you use it, you free it. If you forget to free it, you have a leak. If you use it after freeing it, you get garbage data or a crash. Both of those outcomes teach you something concrete and memorable. The crash is not a catastrophe — it is feedback. The best programmers in the world became the best programmers in the world partly because they spent time with systems that crashed and then made them not crash.</p><p>The borrow checker does not give you that. It gives you a red underline and a compiler message. That is useful for shipping production software. It is much less useful for learning what the machine is actually doing.</p><h3>Who This Hurts</h3><p>The developers who are least harmed by this are the ones who already understand memory management. If you have spent years writing C, worked through your share of segfaults, and understand the lifetime of every allocation you make, then Rust’s borrow checker is a convenience. It catches things you already know to look for and saves you the debugging time.</p><p>The developers who are most harmed are the ones learning for the first time, or the ones who jumped to Rust early in their career because they were told it was the safe choice. For them, the borrow checker is not a helpful assistant — it is a replacement for understanding. They learn to satisfy the compiler without learning what they are actually telling the hardware to do. Their mental model of memory is defined by what the borrow checker accepts, not by what the machine is actually capable of.</p><p>This matters beyond Rust specifically. The culture around memory safety has produced a broader shift in how programmers think about their tools. Languages are valued for how much they protect the programmer from themselves. Compilers are expected to catch everything. AI assistants write the boilerplate. The result is that a lot of people writing code today do not know how to implement a string repeat function from first principles. Not because they are unintelligent — because they have never had to. Every layer of the stack has been insulated by another layer of abstraction, and the actual machine sits underneath it all, completely opaque.</p><h3>What Good Programming Actually Looks Like</h3><p>Good programming is not about writing safe code by default. It is about understanding what your code is doing and making deliberate choices about tradeoffs. A programmer who understands memory can write safe code in C. A programmer who does not understand memory can write Rust that compiles and still produces wrong results, because the borrow checker checks ownership, not logic.</p><p>The goal should be understanding, not guardrails. Learn a language that lets you make mistakes. Write code that crashes. Read the crash. Fix it. Do that enough times and you will develop an intuition for memory that no compiler can give you. Then, if you choose to use a language with safety features, you will use them as tools rather than crutches.</p><p>Memory safety is not a lie because the problems it addresses are fake. Use-after-free bugs are real. Buffer overflows are real. They have caused real security vulnerabilities. The lie is in the framing — the implication that the only way to deal with those problems is to have the compiler refuse to let them happen, and that developers who prefer languages without that feature are being reckless rather than deliberate.</p><p>The machine is simple. An address is an address. Bytes are bytes. A pointer points somewhere, and whatever is there is what you get. Understanding that — really understanding it, not just accepting that the borrow checker says so — is what separates a programmer from someone who knows how to write code.</p><p>One is disappearing. The other should not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90aea81d3f14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Language After Rust and Zig]]></title>
            <link>https://medium.com/@karacvonthweatt/the-language-after-rust-and-zig-b5c2f44c0e57?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5c2f44c0e57</guid>
            <category><![CDATA[zig]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[new-programming-language]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Wed, 08 Jul 2026 16:00:01 GMT</pubDate>
            <atom:updated>2026-07-17T23:36:03.395Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhMw25hz6DN_gytk5jtPYA.png" /></figure><p>Systems programming has been having a moment. After decades of C and C++ as the only real options for performance-critical work, two serious challengers arrived and changed the conversation. Rust pushed the idea that memory safety and zero-cost abstractions can coexist, backed by a borrow checker that enforces ownership at compile time. Zig pushed back by arguing that simplicity, explicit allocation, and comptime evaluation are more honest than a borrow checker, and that the right amount of language is less, not more.</p><p>Both made real contributions. Both have production users, strong communities, and codebases to prove the ideas work. But a newer language called Flux is asking a different question entirely: what if the language trusted you to be a programmer, gave you powerful and composable primitives, stayed out of your way where you didn’t need it, and offered safety tools you could reach for by choice rather than mandated throughout? What if you could have hardware-level control over memory layout, arbitrary-width integer types, opt-in ownership semantics, compile-time contract enforcement, and macro-level metaprogramming, all in a language that reads as cleanly as anything else in the C family?</p><p>This article is an honest comparison. Not a hit piece on either Rust or Zig — both are serious work by serious people. But the tradeoffs they made are real, and Flux makes different ones.</p><h3>The Ownership Problem</h3><p>Rust’s borrow checker is its most famous feature and its most famous source of friction. The core promise is compelling: by tracking ownership and lifetimes throughout your program at compile time, the compiler can guarantee that no two pieces of code mutate the same data simultaneously, that no use-after-free ever occurs, and that no data races are possible in safe code. When it works, it is remarkable. Programs that compile are, in a meaningful sense, correct with respect to a large class of memory errors.</p><p>The cost is real though. You annotate lifetimes on functions three layers deep. You reach for Arc&lt;Mutex&lt;T&gt;&gt; to share state between components in a way that would be two lines in C. You fight the borrow checker over patterns that are obviously correct to a human reader but opaque to a system that must be conservative. The borrow checker is an all-or-nothing proposition: either your entire program is in the system, or you are in unsafe and writing C inside a Rust wrapper. There is no middle ground where you say &quot;I want move semantics on this specific type, but I don&#39;t need the compiler tracking every reference in this module.&quot;</p><p>Zig went the other direction. There are no ownership semantics in the Zig type system at all. Memory safety comes from discipline, explicit allocators, and defer for cleanup. Every function that allocates takes an allocator as a parameter. Nothing is hidden. You know exactly where memory comes from and where it goes because you wrote it. This is honest and predictable, but it leaves the safety guarantees entirely to the programmer&#39;s discipline and code review.</p><p>Flux sits between the two, and the solution is the <strong>tie operator</strong> ~. Ownership in Flux is opt-in at the type level. You apply it to the types and values where it matters, and the rest of your program runs without ownership overhead of any kind, mental or compiled.</p><p>The rules for tied values are deliberately simple:</p><ul><li>A tied value must be explicitly untied on use with the ~ prefix</li><li>A tied value can only move to a parameter or variable of tied type</li><li>Once a value is untied, the original reference is invalidated — use after untie is a compile error</li></ul><pre>def foo(~int z) -&gt; void  // accepts a tied parameter<br>{<br>    return;<br>};<br><br>def main() -&gt; int<br>{<br>    ~int x;<br>    int  y;<br>    foo(~x);   // Untie x from main&#39;s scope, tie it into foo&#39;s parameter<br>    foo(~x);   // Compile error: x has already been untied<br>    foo(y);    // Compile error: foo expects a tied parameter, y is not tied<br>    return 0;<br>};</pre><p>You use this where you actually want it: a raw buffer being handed to an allocator, a file handle that must not be duplicated, a socket that should have one owner. Nowhere else. Nowhere you did not ask for it. The compiler enforces the contract on those specific types while your hash table, your string buffer, and your integer math proceed without a borrow checker in sight.</p><p>This is also consistent with Flux’s broader philosophy: the type system gives you tools you compose deliberately, rather than a global constraint you live inside.</p><h3>Compile-Time Execution</h3><p>Zig’s comptime is one of its best ideas. You mark code comptime and it runs during compilation using the same syntax as runtime code — no separate macro language, no special rules for what you can and cannot write. It is just Zig, running at compile time.</p><p>Flux has the same property, and then goes further in almost every direction.</p><p>Compile-time code in Flux is Flux. You wrap code in a comptime block and it executes during the compiler&#39;s code generation pass, on a dedicated virtual machine — the FVM — that was built specifically to handle compile-time execution and also powers the REPL. You can define functions, declare variables, call functions, do I/O, run loops, branch on conditions — anything you can do at runtime, in the same syntax:</p><pre>#import &lt;standard.fx&gt;;<br><br>comptime<br>{<br>    def foo() -&gt; void<br>    {<br>        compiler.io.console.print(&quot;Hello from compile time!\n&quot;);<br>    };<br>    foo();<br>};<br><br>def main() -&gt; int<br>{<br>    return 0;<br>};</pre><p>This prints Hello from compile time! during compilation, interleaved with the compiler&#39;s own output. Multiple comptime blocks share scope — functions defined in one are callable from another, and variables persist across blocks.</p><p>Rust has no equivalent to this. const fn is a restricted subset of the language that excludes most interesting operations. Procedural macros run at compile time but are a completely separate Rust program operating on token trees, not a Rust function running in the same language with the same syntax. The mental model is fractured across three separate systems. In Flux, compile-time code is just code.</p><p><strong>The FVM goes deeper than that.</strong> Because the compile-time executor is a real virtual machine with its own instruction set, you can drop into raw FVM assembly inside a comptime block using a fluxvm block, operate directly on comptime-scope variables, and have those modifications visible to subsequent Flux comptime code:</p><pre>comptime<br>{<br>    int x = 5;<br><br>    fluxvm<br>    {<br>        LOCAL_GET x<br>        PUSH 10<br>        ADD<br>        LOCAL_SET x<br>    };<br>    compiler.io.console.print(f&quot;FluxVM modified int x = {x}\n&quot;);<br>};</pre><p>After the fluxvm block executes, x is 15 and the print statement sees that value. The FVM instructions operate on the same variable table as the surrounding Flux comptime code. This is not a simulation or a separate address space — it is the same VM that is running the comptime execution, exposed directly.</p><p>And you can dump the FVM assembly of your comptime code to a file for independent execution:</p><pre>compiler.fvm.dump(&quot;my_comptime.fvm&quot;)</pre><p>That file can be executed standalone by the FVM outside of a compilation, which means comptime logic can be extracted, inspected, shared, or reused as independent programs. The compile-time executor is not a black box baked into the compiler. It is a documented, accessible VM with a text assembly format you can read and write directly.</p><p>Compare this to Zig: Zig’s comptime also runs the same language at compile time, which is the right idea, but the compile-time executor is an internal interpreter with no exposed instruction set, no dump capability, and no path to independent execution. What Flux adds is the full stack — a real VM, a readable assembly format, direct inline access to that VM from comptime code, and the ability to treat comptime programs as first-class artifacts.</p><p>Zig also does not have an equivalent to emitflux, which is covered in the next section.</p><p><strong>Named comptime blocks</strong> add another dimension entirely. A comptime block can be given a name, and any comptime code can goto that name like a label. Because comptime blocks share scope, jumping between two named blocks repeatedly is a valid loop:</p><pre>comptime A<br>{<br>    // setup or per-iteration work<br>    goto B;<br>};<br><br>comptime B<br>{<br>    // more work<br>    if (condition) { goto A; };   // loop back<br>    // otherwise fall through and stop<br>};</pre><p>This means the control flow of your comptime execution is not limited to the structured loops and branches inside a single block. You can build arbitrary comptime control flow graphs out of named blocks, with goto as the edge. Combined with emitflux, this means the structure of your code generation can itself be driven by non-linear comptime execution — not just a single loop that emits things in order, but a full state machine at the meta level that decides what to emit and when based on conditions that evolve across block boundaries.</p><h3>Code Generation with emitflux</h3><p>An emitflux block inside a comptime block injects Flux code into the compilation unit at the scope where the enclosing comptime block lives, in the order the emitflux blocks appear. The comptime code is the generator. The emitflux blocks are the output — real Flux definitions that land in the file as if you had written them there by hand, fully type-checked, compiled, and available to the rest of the program.</p><p>The practical consequence is that you can drive code generation with arbitrary Flux logic running at compile time: loops that iterate over data, conditionals that branch on computed values, string interpolation and codification that build identifiers from comptime variables. Whatever the comptime execution produces gets emitted as concrete Flux into the module.</p><p>Here is a complete example — a state machine where the valid transition predicates are generated from a data table rather than written by hand:</p><pre>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br><br>enum State { Idle, Running, Paused, Stopped };<br><br>comptime<br>{<br>    int[] trans_from = [0, 1, 2, 1];<br>    int[] trans_to   = [1, 2, 1, 3];<br>    int   tcount     = 4;<br>    emitflux<br>    {<br>        def state_name(int s) -&gt; byte*<br>        {<br>            if (s == 0) { return &quot;Idle&quot;; };<br>            if (s == 1) { return &quot;Running&quot;; };<br>            if (s == 2) { return &quot;Paused&quot;; };<br>            if (s == 3) { return &quot;Stopped&quot;; };<br>            return &quot;Unknown&quot;;<br>        };<br>    };<br>    for (int tidx = 0; tidx &lt; tcount; tidx++)<br>    {<br>        emitflux<br>        {<br>            def ~$i&quot;can_trans_{}_{}&quot;:{trans_from[tidx];trans_to[tidx];}() -&gt; bool { return true; };<br>        };<br>    };<br>    emitflux<br>    {<br>        def transition(int fx, int to) -&gt; int<br>        {<br>            if (fx == 0 &amp; to == 1 &amp; can_trans_0_1()) { return to; };<br>            if (fx == 1 &amp; to == 2 &amp; can_trans_1_2()) { return to; };<br>            if (fx == 2 &amp; to == 1 &amp; can_trans_2_1()) { return to; };<br>            if (fx == 1 &amp; to == 3 &amp; can_trans_1_3()) { return to; };<br>            println(f&quot;Invalid: {fx}:{state_name(fx)} -&gt; {to}:{state_name(to)}&quot;);<br>            return fx;<br>        };<br>    };<br>};</pre><p>The comptime loop runs four times. Each iteration emits one can_trans_X_Y() function into the module scope. The function name is built from the transition table values: ~$ is the codify operator — the inverse of stringification, turning a string into a valid code identifier — combined with an i-string that interpolates the comptime variables into the name. By the time the final emitflux block emits transition(), all four predicate functions already exist in the compilation unit because they were emitted in order above.</p><p>The result is a complete, type-checked state machine. Adding a new valid transition means adding one entry to the comptime data arrays. The predicate functions, the transition() dispatcher — none of that is touched. The generator produces it all.</p><p>This is what Rust’s procedural macros are attempting to do. But in Rust, that requires a separate crate compiled as a separate program, a separate registration mechanism, and working with token tree manipulation through an API that is distinct from ordinary Rust. You are not writing Rust — you are writing a Rust program that writes Rust tokens. In Flux, you write Flux that writes Flux. Everything is in one file, in one syntax, with a direct and readable relationship between generator and output.</p><h3>Expression Macros</h3><p>Separate from comptime, emitflux, and the FVM, Flux has expression-level macros for inline call-site substitution. A macro definition looks like a function but expands before code generation, substituting its arguments into an expression at every call site:</p><pre>macro xyz(a, b, c)<br>{<br>    (a + b) ^ c<br>};<br><br>println(f&quot;xyz(1,2,3) = {xyz(1, 2, 3)}&quot;);<br>// Expands to: println(f&quot;xyz(1,2,3) = {(1 + 2) ^ 3}&quot;)<br>// Prints: xyz(1,2,3) = 27</pre><p>The macro body is an expression, not a statement list or a token tree. It cannot inject control flow into a call site. It substitutes its arguments and the resulting expression appears at the call site. Macros compose cleanly with contracts — a contract can use macros, and both attach to functions or operators through the same syntax:</p><pre>macro macNZ(x)      { x != 0 };<br><br>contract ctNonZero(a, b)<br>{<br>    assert(macNZ(a), &quot;a must be nonzero&quot;);<br>    assert(macNZ(b), &quot;b must be nonzero&quot;);<br>};</pre><p>Macros can also be self-referential, allowing recursion:</p><pre>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br>macro factorial(n)<br>{<br>    n * factorial(--n) if (n &gt; 1) else n<br>};<br>def main() -&gt; int<br>{<br>    int x = factorial(5);<br>    println(x); // 120<br>    return 0;<br>};</pre><p>Here’s a more advanced example of metaprogramming in Flux:</p><pre>///<br>    metademo.fx -- a CLI calculator whose dispatch is built entirely<br>    at compile time via comptime + emitflux.<br><br>    metaprogramming techniques used:<br>      - macro          : compile-time expression helpers<br>      - comptime       : generate code and print build-time diagnostics<br>      - emitflux       : inject generated Flux source into scope<br>      - $              : stringify identifiers into byte* names<br>      - ~$             : codify strings back into identifiers / source<br>      - i-string       : build identifier names from loop variables<br>      - g-string       : deduplicated global string constants<br>      - self-ref macro : FVM-evaluated factorial baked in as a constant<br>///<br><br>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br><br>// -------------------------------------------------------------------<br>// Step 1: macros<br>// -------------------------------------------------------------------<br><br>macro clamp(v, lo, hi)<br>{<br>    (v if (v &gt; lo) else lo) if ((v if (v &gt; lo) else lo) &lt; hi) else hi<br>};<br><br>// self-referential -- FVM constant-folds entirely at compile time<br>macro ct_fact(n)<br>{<br>    n * ct_fact(--n) if (n &gt; 1) else n<br>};<br><br>// stringify a variable name and print it alongside its value<br>macro named_print(val)<br>{<br>    println(f&quot;{$val} = {val}&quot;)<br>};<br><br>// number of ops -- change this and everything below regenerates<br>#def NUM_OPS 4;<br><br>// -------------------------------------------------------------------<br>// Step 2: comptime generates one handler per op, a dispatch function<br>//         with a generated switch body, and a names table<br>// -------------------------------------------------------------------<br><br>comptime<br>{<br>    byte*[NUM_OPS] op_names = [&quot;add&quot;, &quot;sub&quot;, &quot;mul&quot;, &quot;div&quot;],<br>                   op_syms  = [&quot;+&quot;,   &quot;-&quot;,   &quot;*&quot;,   &quot;/&quot;],<br>                   op_exprs = [&quot;a + b&quot;, &quot;a - b&quot;, &quot;a * b&quot;, &quot;a / b&quot;];<br><br>    compiler.io.console.println(&quot;[comptime] generating op handlers...&quot;);<br><br>    // emit one handler function per op<br>    int i;<br>    byte* nm, expr;<br>    while (i &lt; NUM_OPS)<br>    {<br>        nm   = op_names[i];<br>        expr = op_exprs[i];<br><br>        compiler.io.console.println(f&quot;[comptime]   op_{nm}&quot;);<br><br>        emitflux<br>        {<br>            def ~$i&quot;op_{}&quot;:{nm} (int a, int b) -&gt; int { return ~$expr; };<br>        };<br><br>        i++;<br>    };<br><br>    // emit dispatch(int id, int a, int b) -&gt; int<br>    // body is a switch with one generated case per op<br>    compiler.io.console.println(&quot;[comptime] generating dispatch...&quot;);<br><br>    emitflux { def dispatch(int id, int a, int b) -&gt; int;  };<br><br>    // we need to emit the full function body as one emitflux,<br>    // so build the case list by emitting each case individually<br>    // inside a generated function shell<br><br>    // emit the switch shell open<br>    emitflux<br>    {<br>        def dispatch(int id, int a, int b) -&gt; int<br>        {<br>            switch (id)<br>            {<br>    }#;<br><br>    // emit one case per op<br>    int j, jv;<br>    while (j &lt; NUM_OPS)<br>    {<br>        nm = op_names[j];<br>        jv = j;<br><br>        emitflux<br>        {<br>                case (~$i&quot;{}&quot;:{jv;}) { return ~$i&quot;op_{}&quot;:{nm;} (a, b); }<br>        };<br><br>        j++;<br>    };<br><br>    // close the switch and function<br>    emitflux<br>    {<br>                default { return -1; };<br>           #};<br>       #};<br>    };<br><br>    // emit the op name and symbol tables as plain arrays<br>    emitflux<br>    {<br>        byte*[NUM_OPS] g_op_names = [g&quot;add&quot;, g&quot;sub&quot;, g&quot;mul&quot;, g&quot;div&quot;],<br>                       g_op_syms  = [g&quot;+&quot;,   g&quot;-&quot;,   g&quot;*&quot;,   g&quot;/&quot;];<br>    };<br><br>    int fingerprint = ct_fact(6);<br>    compiler.io.console.println(f&quot;[comptime] fingerprint = {fingerprint}&quot;);<br><br>    emitflux<br>    {<br>        int g_fingerprint = ~$f&quot;{fingerprint}&quot;;<br>    };<br><br>    compiler.io.console.println(&quot;[comptime] done.&quot;);<br>};<br><br>// -------------------------------------------------------------------<br>// Step 3: runtime<br>// -------------------------------------------------------------------<br><br>def usage(byte* prog) -&gt; void<br>{<br>    println(f&quot;usage: {prog} &lt;op&gt; &lt;a&gt; &lt;b&gt;&quot;);<br>    println(g&quot;ops:&quot;);<br>    int i = 0;<br>    while (i &lt; NUM_OPS)<br>    {<br>        println(f&quot;  {g_op_names[i]}  ({g_op_syms[i]})&quot;);<br>        i++;<br>    };<br>    println(f&quot;build fingerprint: {g_fingerprint}&quot;);<br>};<br><br>def find_op(byte* name, int len) -&gt; int<br>{<br>    int i, j, match;<br>    byte* candidate;<br>    while (i &lt; NUM_OPS)<br>    {<br>        candidate = g_op_names[i];<br>        j         = 0;<br>        match     = 1;<br><br>        while (j &lt; len)<br>        {<br>            { match = 0; break; } if (name[j] != candidate[j]);<br>            j++;<br>        };<br><br>        { return i; } if (match == 1);<br>        i++;<br>    };<br>    return -1;<br>};<br><br>def main() -&gt; int<br>{<br>    int demo = clamp(42, 0, 100);<br>    named_print(demo);<br><br>    byte* prog    = g&quot;metademo&quot;;<br>    byte* op_name = g&quot;div&quot;;<br>    int   op_len  = 3;<br>    int   a       = 21;<br>    int   b       = 3;<br><br>    int op_id = find_op(op_name, op_len);<br><br>    if (op_id &lt; 0)<br>    {<br>        println(g&quot;unknown op&quot;);<br>        usage(prog);<br>        return 1;<br>    };<br><br>    int result = dispatch(op_id, a, b);<br><br>    println(f&quot;{a} {g_op_syms[op_id]} {b} = {result}&quot;);<br>    println(f&quot;stored in &#39;{$result}&#39;: {result}&quot;);<br><br>    return 0;<br>};</pre><h3>Templates</h3><p>Templates in Flux are type substitution. No SFINAE, no concept maps, no enable_if, no multi-line where clauses. They apply to functions, structs, objects, and operator definitions, and the compiler infers template parameters at call sites so angle brackets stay out of everyday code:</p><pre>def foo&lt;T&gt;(T x) -&gt; T { return x; };<br><br>int z   = foo(3);     // T inferred as int<br>float y = foo(5.5f);  // T inferred as float</pre><p>Where Flux’s template system goes beyond Rust or Zig is <strong>constraint sets</strong> — named, reusable relational expressions that describe not just properties of a single type but how a family of types may interact throughout a template body:</p><pre>constraint NoNarrowing(A)<br>{<br>    A !`&lt; A    // A must never be narrowed anywhere in this template body<br>};<br><br>def serialize&lt;T: int, :{NoNarrowing}&gt;(T x) -&gt; byte<br>{<br>    return 5 + x;   // Compile error: narrowing T to byte violates NoNarrowing<br>};</pre><p>The !&lt;operator is verified by walking the instantiated function body — not checked against a declaration, but found by analysis of actual operations. The example errors because5 + xwithx: intreturned intobyte` is an implicit narrowing, and the compiler finds it. Circular multi-parameter expressions describe type geometry in a single line:</p><pre>D !~= B &amp; [A !@ A] !~= C !`&lt; D !-= A</pre><p>Values of type A cannot have their address taken. D must be incompatible with B and A. B and A must be incompatible with C. C and D cannot appear on either side of a narrowing. D cannot be used in signed operations with A. This is not “T must implement Trait.” It is a relational specification of how a family of types may and may not interact, verified by the compiler across the entire template body.</p><h3>Safety You Compose, Not Safety You Survive</h3><p>Rust’s safety guarantee is structural: if it compiles without unsafe, a well-defined set of memory errors cannot occur. The tradeoff is friction, annotation, and the fact that the borrow checker is a conservative approximation that rejects some correct programs.</p><p>Zig’s safety guarantee is operational: sanitizers catch issues at runtime in debug builds, and you have an allocator and defer, and the language is simple enough that you can reason about it carefully. There is no type-level enforcement beyond what you build by convention.</p><p>Flux adds <strong>contracts</strong>, which are named code blocks you attach to functions as part of their specification. A contract ends up inside the function body. It is a modifier on the function’s declaration that the compiler splices into the generated code. Pre-contracts go before the function body. Post-contracts go before each return:</p><pre>contract NonZero(a, b)<br>{<br>    assert(a != 0, &quot;a must be nonzero&quot;);<br>    assert(b != 0, &quot;b must be nonzero&quot;);<br>};<br><br>contract ResultPositive(a, b)<br>{<br>    assert(a + b &gt; 0, &quot;result must be positive&quot;);<br>};<br><br>def add(int x, int y) -&gt; int : NonZero(a, b)<br>{<br>    return x + y;<br>} : ResultPositive(a, b);</pre><p>The contract transforms the function into:</p><pre>def add(int x, int y) -&gt; int<br>{<br>    assert(x != 0, &quot;a must be nonzero&quot;);<br>    assert(y != 0, &quot;b must be nonzero&quot;);<br>    assert(x + y &gt; 0, &quot;result must be positive&quot;);<br>    return x + y;<br>};</pre><p>Contracts can go on operator overloads. If you define a custom addition operator for a BigInt type, you can attach a contract that verifies invariants on every call without that logic living inside the function itself:</p><pre>operator (int L, BigInt R) [+] -&gt; BigInt : NonZero(L, R)<br>{<br>    // Implementation<br>};</pre><p>The contract runs on every dispatch to that overload. The verification is real. The overhead is proportional to what you assert, not to a global memory model.</p><p><strong>Traits</strong> in Flux serve the same role as in Rust — enforcing interface compliance at compile time — but without the orphan rules, coherence requirements, or the separation between defining a trait and implementing it that makes Rust trait code fragile across crate boundaries. A trait is a list of prototypes an object must implement:</p><pre>trait Drawable<br>{<br>    def draw() -&gt; void;<br>};<br><br>Drawable object myObj<br>{<br>    def __init() -&gt; this { return this; };<br>    def __exit() -&gt; void {};<br>    def __expr() -&gt; myObj* { return this; };<br>    def draw() -&gt; void<br>    {<br>        // Must have a body; an empty implementation is a compile error<br>    };<br>};</pre><p><strong>Interfaces</strong> go further than traits by restricting which methods two objects may call on each other to an explicitly declared list. Calling any method not in the interface’s listed set — even a public one — is a compile error:</p><pre>interface Stream(A: Readable, B: Writable)<br>{<br>    A : B { read(byte*,int)-&gt;int, write(byte*,int)-&gt;int, flush()-&gt;int };<br>    B : A { ack()-&gt;int };<br>};<br><br>object Pipe {} : Stream(this, Socket);</pre><p>Once Pipe declares this interface, the compiler verifies at every Socket call site that the method being called is in the declared list. Socket does not need to know about the interface. The enforcement is on Pipe&#39;s use of Socket, not on Socket&#39;s definition. This is a different and often more practical model than Rust&#39;s, where coherence rules dictate what can be implemented where.</p><p><strong>Deprecation</strong> is a first-class language feature rather than a compiler attribute or documentation convention:</p><pre>deprecate test1::test2;</pre><p>Referencing a deprecated namespace anywhere in the program is a compile error with a precise message showing the call site. You cannot accidentally leave uses of a deprecated API in a codebase. The compiler will not compile until they are removed.</p><h3>A Data Model Built for Hardware</h3><p>Rust’s type system thinks in structs, enums (which are really tagged unions), and references. It has u8, u16, u32, u64, and so on. If you need a 13-bit integer, you use a u16 and mask manually, or you reach for a proc macro crate like bitfield. The language does not have a concept of arbitrary-width integers as first-class types.</p><p>Zig has packed structs and a more explicit integer width system (u13, i7, etc.) that gets you closer. But the control over alignment, endianness, and the ability to chain type aliases is not there.</p><p>Flux has the data keyword, which creates arbitrary-width integer types as first-class language citizens:</p><pre>signed data{13:16} as strange13;     // 13-bit signed, 16-bit aligned<br>unsigned data{3} as tiny;            // 3-bit unsigned, values 0-7<br>unsigned data{7:8} as aligned7;      // 7-bit with 8-bit alignment<br>unsigned data{5}[10] as 5b_array;    // Array of 5-bit values</pre><p>The full specification is data{width : alignment : endianness}. Big-endian is the default. Little-endian is specified as the third parameter with 0:</p><pre>data{16::0} as le16;   // Little-endian 16-bit<br>data{16}    as be16;   // Big-endian 16-bit (default)</pre><p>Endian conversion in Flux is handled by assignment between types of different endianness — the compiler emits the byte swap. There is no byteswap intrinsic to remember to call. There is no htons/ntohs family. You assign a be16 to an le16 and the swap happens:</p><pre>def network_to_host(be16 net_value) -&gt; le16<br>{<br>    le16 x = net_value;   // Byte swap emitted automatically<br>    return x;<br>};</pre><p>All math is performed in a single endianness internally. Mixed-endian arithmetic does not silently produce the wrong answer because there is no mixed-endian arithmetic — the conversion happens at assignment, not mid-expression.</p><p>You can also type-pun chains of data aliases:</p><pre>unsigned data{16} as dbyte;<br>dbyte as xbyte;<br>xbyte as ybyte;<br>ybyte as zbyte zbx = 0xFF;</pre><p>Each alias is a distinct type for the compiler’s purposes. endianof, alignof, sizeof, and typeof are built-in operators that return properties of any type:</p><pre>sizeof(strange13);    // 13 (bits)<br>alignof(strange13);   // 16<br>typeof(strange13);    // &quot;signed data{13:16}&quot;<br>endianof(strange13);  // 1 (big-endian)</pre><p>This is the type system that networking code, cryptography implementations, hardware register maps, and binary protocol parsers actually need. You do not reach for a proc macro crate or maintain a packed_struct wrapper. You write the type you mean.</p><h3>The Bit Manipulation Story</h3><p>One of the most tedious aspects of systems programming is bit manipulation. Extracting a field from a packed register. Replacing a range of bits in place. Converting between array representations and integer representations. Every language leaves you writing the same masking and shifting patterns over and over.</p><p>Flux has the <strong>bit-slice operator</strong> \`` which extracts a range of bits from any integer-width value and returns it as a value of the appropriate width:</p><pre>u32 packed = 0x12345678;<br>u32 nibble0 = packed[0``3];    // Bits 0-3:   0x8<br>u32 nibble3 = packed[12``15];  // Bits 12-15: 0x5<br>u32 byte1   = packed[8``15];   // Bits 8-15:  0x56</pre><p>Assignment into a bit slice replaces just that range in place, leaving every other bit untouched:</p><pre>u32 packed = 0x12345678;<br>packed[24``31] = 0xFF;<br>// packed == 0x123456FF</pre><p>This eliminates entire categories of (value &amp; mask) &gt;&gt; shift boilerplate. The start and end indices must be compile-time constants, so the compiler can verify correctness and generate the right mask in one step.</p><p><strong>Array-to-integer packing</strong> takes this further. Casting a fixed-size array to an integer type packs the array element-by-element into the integer, with element 0 occupying the most significant bits. This is defined behavior with a consistent convention, not implementation-defined. The consequence is that multi-byte big-endian operations that take 16 lines in C can take one in Flux:</p><p>C:</p><pre>len_block[0]  = (byte)((aad_bits &gt;&gt; 56) &amp; 0xFF);<br>len_block[1]  = (byte)((aad_bits &gt;&gt; 48) &amp; 0xFF);<br>len_block[2]  = (byte)((aad_bits &gt;&gt; 40) &amp; 0xFF);<br>len_block[3]  = (byte)((aad_bits &gt;&gt; 32) &amp; 0xFF);<br>len_block[4]  = (byte)((aad_bits &gt;&gt; 24) &amp; 0xFF);<br>len_block[5]  = (byte)((aad_bits &gt;&gt; 16) &amp; 0xFF);<br>len_block[6]  = (byte)((aad_bits &gt;&gt;  8) &amp; 0xFF);<br>len_block[7]  = (byte)( aad_bits        &amp; 0xFF);</pre><p>Flux:</p><pre>len_block[0..7] = (byte[8])(u64)aad_bits;</pre><p>The array comprehension syntax makes bulk initialization similarly expressive:</p><pre>int[10] squares = [x ^ 2 for (int x in 1..10)];<br>int[20] evens   = [x     for (int x in 1..20) if (x % 2 == 0)];</pre><p>Python-style and C-style comprehension both work. You can also comprehend over dynamic collections:</p><pre>Array[] filtered = [x.name for (Array x in oldArr) if (x.name.len() &gt; 5)];</pre><h3>Structs, Objects, and the Separation Between Data and Behavior</h3><p>C++ conflated data and behavior in classes, giving you a type that could be both a plain data container and a method-laden object. This was convenient but blurred the distinction between things that are just memory layouts and things that are executable. Rust’s structs and impl blocks separate layout from behavior but do not enforce that one particular kind of type is <em>only</em> data.</p><p>Flux makes the separation explicit and enforced at the language level. <strong>Structs</strong> are data only:</p><pre>struct Header<br>{<br>    data{16} sig;<br>    data{32} filesize, reserved, dataoffset;<br>};</pre><p>Placing any executable statement — a for loop, an if block, a try/catch, a function definition — inside a struct is a compile error. Structs cannot contain functions or objects. They can contain pointers, including function pointers. They are tightly packed with no padding unless alignment is specified in the type. This is not something you configure with #[repr(packed)] or a pragma. It is the default and the only layout.</p><p>Struct composition is done directly in the definition without OOP inheritance ceremony:</p><pre>struct BMP : Header, InfoHeader<br>{<br>    // Additional BMP fields<br>} : ExtraData;</pre><p>This prepends and appends fields from the named structs. No vtables. No runtime polymorphism. Just “the layout of BMP includes these fields from these structs in this order.”</p><p><strong>Objects</strong> are the executable counterpart. They can contain methods, use this, and have lifecycle management through required methods:</p><pre>object SomeObj<br>{<br>    int val;<br><br>    def __init(int x) -&gt; this<br>    {<br>        this.val = x;<br>        return this;<br>    };<br><br>    def __exit() -&gt; void {};<br><br>    def __expr() -&gt; int { return this.val; };<br>};</pre><p>__init is the constructor, called on instantiation. __exit is the destructor, called manually or via defer. __expr is the expression context method — when an object instance appears in an expression context, the compiler calls this and uses its return value. So println(sobj) becomes println(sobj.__expr()) automatically.</p><p>If __init takes exactly one parameter, you can instantiate with assignment syntax:</p><pre>SomeObj sobj = 5;    // Equivalent to SomeObj sobj(5);</pre><p><strong>Object inheritance</strong> in Flux is designed to eliminate the diamond problem rather than work around it. A child object inherits all non-private, non-mandatory members from its parents. If two parents have a method with matching signatures but different implementations, the compiler errors. The child does not inherit mandatory methods (__init, __expr, __exit) and must define its own. Multiple inheritance is expressed as object C : A, B. The !+ modifier marks a method as non-overridable, and attempting to override it in a child is a compile error.</p><p>The separation between struct and object also matters for templates: struct template parameters cannot be of object type, because objects are not pure data. The compiler enforces this. You cannot accidentally instantiate a struct template with a type that carries behavior.</p><h3>Error Handling Without a Return Type Tax</h3><p>Rust’s error handling uses the Result&lt;T, E&gt; type and the ? propagation operator. It is clean, compositional, and enforced: you cannot accidentally ignore an error because the return value is a Result that you must handle or propagate explicitly. The cost is that every function in a call chain that can fail must have its return type annotated with Result, and the error type must propagate consistently or be converted.</p><p>Zig uses explicit error unions (!T) and try for propagation. The error set is part of the type and can be inferred. This is cleaner than Rust in some ways — the error types are values not trait objects — but it still means annotating every function in the chain.</p><p>Flux uses try/throw/catch with typed catches that dispatch on the thrown type. This is structurally similar to C++ exceptions but without the hidden stack unwinding cost — the design is explicit call-site dispatch rather than a global unwind table:</p><pre>object ERR<br>{<br>    byte* message;<br>    def __init(byte* m) -&gt; this { this.message = m; return this; };<br>    def __exit() -&gt; void {};<br>    def __expr() -&gt; byte* { return this.message; };<br>};<br><br>def myErr(int code) -&gt; void<br>{<br>    switch (code)<br>    {<br>        case (0)<br>        {<br>            ERR e(&quot;Custom error\0&quot;);<br>            throw(e);<br>        }<br>        default<br>        {<br>            throw(&quot;Default error\0&quot;);<br>        };<br>    };<br>};<br><br>def main() -&gt; int<br>{<br>    try<br>    {<br>        myErr(0);<br>    }<br>    catch (ERR e)        // Typed catch: dispatches on ERR object<br>    {<br>        byte* msg = e.message;<br>    }<br>    catch (byte* s)      // Typed catch: dispatches on raw string<br>    {<br>    }<br>    catch (auto x)       // Catch-all<br>    {<br>    };<br>    return 0;<br>};</pre><p>Catches dispatch in order on the thrown type. auto is the catch-all. assert integrates with the try/catch system: inside a try block, a failed assert throws the assertion message as a string rather than writing to stderr, so you can catch assertion failures with the same mechanism as thrown errors.</p><p>The practical difference from Rust’s model is that functions in the middle of a call chain do not need to annotate their return types with a result type to propagate errors. A function that might throw simply throws. The catch happens where you want to handle it. For many patterns — particularly in systems code where you want to catch errors at a high level and log or recover — this is less boilerplate than threading Result through every layer.</p><h3>The Operator System</h3><p>Rust allows operator overloading through trait implementations. The set of overloadable operators is fixed. You implement std::ops::Add for your type and + dispatches to it. This is clean but limited to the existing operator set, and implementing it requires understanding the trait system and lifetime annotations on the return type.</p><p>Zig has no operator overloading.</p><p>Flux has a complete operator system that allows both overloading existing operators and defining entirely new ones:</p><pre>// New operator<br>operator (int L, int R) [+++] -&gt; int<br>{<br>    return ++L + ++R;<br>};<br><br>int result = a +++ b;   // Dispatches to the custom operator<br><br>// Identifier-based operator<br>operator (int L, int R) [NOPOR] -&gt; bool<br>{<br>    return !L | !R;<br>};<br><br>bool check = a NOPOR b;</pre><p>Overloading built-in operators follows two rules: one parameter must not be a built-in type (so you cannot silently override integer addition), and the overload’s precedence and associativity cannot be changed from the built-in symbol’s. These rules prevent the most common overloading abuses while leaving the useful cases open.</p><p>Custom operators also accept contracts:</p><pre>operator (int L, BigInt R) [+] -&gt; BigInt : ValidOperands(L, R)<br>{<br>    // Implementation<br>};</pre><p>Every dispatch to this overload runs ValidOperands first. The contract is part of the operator&#39;s specification, not its implementation.</p><p>Templated operators instantiate lazily on first use with concrete types:</p><pre>operator&lt;T&gt; (T L, T R) [+] -&gt; T<br>{<br>    // Generic implementation<br>};</pre><p>Each time this appears in code with a new concrete pair of types, a new overload is generated for that pair.</p><p>Soon, Flux will allow you to create prefix and postfix operators, not just infix, as well as specify precedence.</p><h3>Type Functions and the Method Call Syntax Problem</h3><p>Rust puts methods on types through impl blocks, which are separate from the type definition and can appear anywhere. This means the method set of a type is open — anyone can add methods to any type in any file. Zig has no method syntax; you call TypeName.function(value, args) with the first parameter being the receiver.</p><p>Flux has <strong>type functions</strong>, which extend any type with dot-call syntax without the overhead of object definitions or the open-world problem of impl blocks:</p><pre>byte*.reverse() -&gt; byte*<br>{<br>    // _ is the receiver, equivalent to `this`<br>    // implementation...<br>};<br><br>println(&quot;world&quot;.reverse());   // Calls the above</pre><p>You can do this for built-in types, struct types, and pointer types. The receiver is _ inside the function. You can also use &quot;&quot; as shorthand for the string type:</p><pre>&quot;&quot;.add_world() -&gt; &quot;&quot;<br>{<br>    return _ + &quot;, World!&quot;;<br>};<br><br>byte* greeting = &quot;Hello&quot;.add_world();  // &quot;Hello, World!&quot;</pre><p>Literal modifier functions let you define behavior that attaches to literal suffixes:</p><pre>0.my_int_func() -&gt; int   // Attaches to integer literals: 55.my_int_func()<br>{<br>    return _;<br>};</pre><p>Tied types can have type functions too:</p><pre>~byte*.consume() -&gt; ~byte*<br>{<br>    return _[0] - 11;<br>};</pre><p>This means the ownership semantics propagate through type function calls the way you would expect: calling a type function on a tied value moves the tied value into the function’s scope.</p><p>To disallow a type from having functions, you must create a primitive with data! like so:</p><pre>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br><br>data!{32} as u32i;<br><br>u32i.foo() -&gt; u32i { return 0u; };<br><br>def main() -&gt; int<br>{<br>    return 0;<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PX-d_EUChYNQWi5gC4RzvQ.png" /><figcaption>Real screenshot of Flux enforcing functionless types with an error.</figcaption></figure><h3>Control Flow That Says What It Means</h3><p>Rust’s control flow is mostly conventional C with match as the flagship addition. Zig&#39;s control flow is simpler than C&#39;s in some ways — no implicit fallthrough in switch, for example — but does not add much beyond the explicit.</p><p>Flux makes deliberate decisions about control flow that make code more readable and less error-prone.</p><p><strong>elif</strong> is a first-class keyword rather than else if, following Python&#39;s lead and reducing a common visual indentation problem:</p><pre>if (x &gt; 0)      { doThis(); }<br>elif (x &lt; 0)    { doThat(); }<br>else            { doDefault(); };</pre><p><strong>Switch statements</strong> do not fall through between cases. Each case is its own block. Exiting a switch uses break switch; rather than bare break, so when a switch is inside a loop, a break unambiguously exits the loop rather than the switch:</p><pre>for (int i = 0; i &lt; n; i++)<br>{<br>    switch (values[i])<br>    {<br>        case (0)<br>        {<br>            // handle zero<br>            break switch;   // Exits the switch<br>        }<br>        case (1)<br>        {<br>            if (done) { break; };   // Exits the for loop<br>        }<br>        default<br>        {<br>            continue;   // next iteration of the for loop<br>        };<br>    };<br>};</pre><p>There is no ambiguity. break switch means the switch. break means the nearest enclosing loop. They are different things with different syntax.</p><p><strong>The </strong><strong>in keyword </strong>works as both a loop iterator and a membership test in any expression context:</p><pre>int[5] arr = [1, 2, 3, 4, 5];<br>if (3 in arr) { found(); };<br><br>int[2] pair = [3, 4];<br>if (pair in arr) { contiguous_match(); };<br><br>byte* s = &quot;Hello World&quot;;<br>if (&quot;World&quot; in s) { substring_found(); };</pre><p>A single operator handles value membership, sub-sequence search, and substring search depending on the types involved. The intent is readable at the call site without needing a method name to explain what is happening.</p><p><strong>singinit</strong> variables initialize exactly once across all calls to a function, providing static-local-like semantics without file-scope pollution:</p><pre>def counter() -&gt; void<br>{<br>    singinit int x;   // x initializes to 0 on first call, retains value on subsequent calls<br>    x += 1;<br>    print(x);<br>};</pre><p><strong>Strict tail recursion</strong> with &lt;~ guarantees zero stack growth for recursive functions and is a compile-time enforcement rather than an optimizer hint:</p><pre>def recurse() &lt;~ void<br>{<br>    // Function always returns to itself<br>    // musttail is emitted; stack frame cannot grow<br>};</pre><p>If you write code in a &lt;~ function that would prevent tail-call optimization, the compiler errors. You can break out of strict recursion with escape to jump to a different function, which is the only way to exit a &lt;~ function to a non-self target, used like escape other_func(); .</p><h3>Memory Management Without the Ceremony</h3><p>Rust’s memory management comes from the borrow checker plus smart pointers like Box, Rc, and Arc. Knowing when to use which, and how to structure your data to avoid reference cycles in Rc, is a substantial part of the Rust learning curve. The stack vs. heap distinction is mostly implicit — let x = 5 is stack, Box::new(5) is heap.</p><p>Zig is explicit about everything: you call allocator.alloc(), you call allocator.free(), and you use defer to ensure cleanup. The allocator is a parameter you thread through your code. This is completely honest but adds boilerplate.</p><p>Flux makes the distinction explicit with syntax rather than with a separate type hierarchy:</p><pre>int x = 5;        // Stack allocated<br>heap int y = 5;   // Heap allocated; y is a pointer</pre><p>Deallocation uses the void cast, which also works on stack variables (zeroing them and invalidating the reference):</p><pre>(void)y;   // Frees the heap allocation; y is no longer valid</pre><p>The defer keyword handles cleanup in the same LIFO order as Zig, but in Flux defer can be a block:</p><pre>heap int* buffer = allocate_thing();<br>defer<br>{<br>    cleanup_side_effects();<br>    (void)buffer;   // Freed last, after side effects are cleaned up<br>};<br><br>// Work with buffer here; cleanup is guaranteed on any return path</pre><p>Deferred statements execute after post-contract code and immediately before the function returns, in reverse declaration order. This makes resource cleanup predictable and composable without an RAII wrapper type.</p><h3>Performing Inline ASM</h3><p>All three languages support inline assembly. In Rust it is asm! with a domain-specific argument syntax. In Zig it is @asm with explicit I/O binding. Both work. Neither is especially readable.</p><p>Flux uses AT&amp;T-style assembly in an explicit block with architecture guards and standard constraint syntax:</p><pre>def _exchange64(i64* ptr, i64 value, i64* out) -&gt; void<br>{<br>    #ifdef __ARCH_X86_64__<br>    volatile asm<br>    {<br>        movq $0, %rsi<br>        movq $2, %rdi<br>        movq $1, %rax<br>        xchgq %rax, (%rsi)<br>        movq %rax, (%rdi)<br>    } : : &quot;r&quot;(ptr), &quot;r&quot;(value), &quot;r&quot;(out) : &quot;rax&quot;, &quot;rsi&quot;, &quot;rdi&quot;, &quot;memory&quot;;<br>    #endif;<br>    #ifdef __ARCH_ARM64__<br>    volatile asm<br>    {<br>    .retry_xchg64:<br>        ldaxr x0, [$0]<br>        stlxr w3, x1, [$0]<br>        cbnz  w3, .retry_xchg64<br>        str   x0, [$2]<br>    } : : &quot;r&quot;(ptr), &quot;r&quot;(value), &quot;r&quot;(out) : &quot;x0&quot;, &quot;w3&quot;, &quot;memory&quot;;<br>    #endif;<br>};</pre><p>The pattern outputs : inputs : clobbers follows GCC&#39;s inline assembly convention, which means programmers who already know how to write inline assembly in C can write it in Flux without learning a new constraint language. The volatile tag tells the compiler to not touch the block under any circumstances. The #ifdef __ARCH_*__ guards are preprocessor directives that let you write one function with platform-specific implementations, all in one place.</p><p>This matters for systems code in a way that higher-level languages can wave away. Writing a compare-and-swap, a spinlock, or a hardware I/O operation requires inline assembly in most cases. Having a readable, familiar interface to it — rather than a domain-specific macro language bolted on top — reduces the chance of getting the constraints wrong.</p><h3>The Tooling Picture</h3><p>Flux compiles to native code via LLVM, which means it has access to the same optimization passes and target backend support as Rust and Zig. The fxc.py compiler frontend handles lexing, parsing, type checking, and LLVM IR generation. A VM interpreter (fvm.py) exists for development and debugging, allowing programs to be run and traced without a full compile-link cycle.</p><p>The package manager fpm handles dependencies with local registry storage. Libraries compile to .so on Linux and .dll on Windows with the same source-level export syntax:</p><pre>export<br>{<br>    def !!my_function() -&gt; void {};<br>};</pre><p>The !! prefix suppresses name mangling, making the export link-compatible with C. You can call any Flux library from C and vice versa using the same extern declaration mechanism that declares external functions. Alternatively you can declare the calling convention as cdecl:</p><pre>export<br>{<br>    cdecl my_function() -&gt; void {};<br>};</pre><p>For interoperating with existing C codebases, a translation tool called cft parses C headers and source files using libclang and emits Flux equivalents. This handles the majority of mechanical translation: function prototypes become extern declarations, typedef pointer chains become Flux type aliases, struct definitions become Flux structs, switch statements emit break switch correctly, and raw pointer arithmetic is preserved for manual review. The tool is not a perfect translator — macro-heavy C code requires manual intervention — but for coreutils-scale C codebases it produces a readable starting point.</p><h3>What Flux Is Not Claiming</h3><p>Flux isn’t claiming to be formally verified. It does not generate proofs. It does not use linear types in the sense that Idris or ATS do. The tie operator is a practical ownership model, not a full affine type system.</p><p>Flux is not claiming that its error handling is better than Rust’s Result in every context. For a large library where you want callers to be statically forced to handle every failure case, typed returns are a better fit. The try/throw/catch model is better for systems code where you want to catch errors at a high level rather than threading a result type through twenty call frames.</p><p>Flux is not claiming to be Rust’s replacement in organizations where the borrow checker’s guarantees are worth the friction. Those organizations exist and their choice is justified.</p><p>What Flux is claiming is that there is a large and underserved space between “fight the borrow checker” and “rely entirely on discipline.” A space where a programmer who knows what they are doing wants real safety tools — ownership on specific types, contracts on functions, trait enforcement on interfaces, compile-time constraint verification on templates — without a global memory model they have to opt into for their entire program. A space where the type system is expressive enough to describe a 13-bit signed integer with 16-bit alignment and big-endian byte order as a first-class type, not an abstraction on top of a u16. A space where bit manipulation is readable, control flow says what it means, and the language assumes you are a professional.</p><p>That is the space Flux is designed for, and it’s a space both Rust and Zig left open.</p><p><em>Flux is an actively developed systems programming language. Source code, the full language specification, and the community Discord are available at the </em><a href="https://github.com/kvthweatt/Flux"><em>Flux GitHub repository</em></a><em>. Try the </em><a href="https://fluxspl.org/ide"><em>online compiler!</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5c2f44c0e57" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Algebraic Types?]]></title>
            <link>https://medium.com/@karacvonthweatt/algebraic-types-7c548a3fadce?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c548a3fadce</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[comptime]]></category>
            <category><![CDATA[relational-interfaces]]></category>
            <category><![CDATA[type-theory]]></category>
            <category><![CDATA[flux]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 23:35:32 GMT</pubDate>
            <atom:updated>2026-06-13T00:02:10.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>Algebraic Types? Type Geometry? How Far Can a Language Be Pushed? Compile-Time Execution, Relational Interfaces, and More</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFhKSRFNug2p8JlKqkg3eg.png" /></figure><p>Flux is a compiled, stack-first, general-purpose language with a refreshingly direct philosophy: you own your memory, you write your intent, and the compiler takes you seriously. If you haven’t looked at it in a while — or at all — now is a great time to pay attention.</p><p>Over the past development cycle, Flux has gained several major features that collectively shift it from a capable low-level language into something with serious expressive power. Let’s walk through what’s new.</p><h3>1. Compile-Time Execution with comptime</h3><p>This is the headline feature. Flux can now execute Flux at compile time, powered by a dedicated VM built specifically for this purpose. The same VM will also power the upcoming REPL.</p><p>The model is simple: wrap any code in a comptime block and it runs during the compilation pass, before any runtime code is generated.</p><pre>#import &lt;standard.fx&gt;;<br><br>comptime<br>{<br>    def foo() -&gt; void<br>    {<br>        compiler.io.console.print(&quot;Hello from compile time!\n&quot;);<br>    };<br><br>    foo();<br>};<br><br>def main() -&gt; int<br>{<br>    return 0;<br>};</pre><p>When you compile this, Hello from compile time! prints in the middle of the compiler&#39;s own output — during the AST codegen pass. It&#39;s not a preprocessor macro, it&#39;s not a constexpr evaluation hack. It&#39;s real Flux code running in a VM while your program is being compiled.</p><p>You can split comptime work across multiple blocks, and they share scope:</p><pre>comptime<br>{<br>    def greet(int n) -&gt; void<br>    {<br>        compiler.io.console.print(f&quot;Step {n} complete\n&quot;);<br>    };<br>};<br><br>comptime<br>{<br>    greet(1);<br>    greet(2);<br>};</pre><h3>What’s Already Supported</h3><p>A large portion of the Flux keyword set is available at comptime right now. The full list of what’s live:</p><p>and, as, bool, byte, case, char, constraint, data, def, default, do, double, elif, else, emitflux, enum, false, float, for, goto, if, int, is, label, long, not, or, return, signed, sizeof, struct, switch, true, uint, ulong, union, unsigned, while</p><p>Control flow, arithmetic, structs, enums, unions, loops, conditionals — the core of the language is already there. Standard I/O and file I/O work. Networking is deferred to a future update.</p><p>A few keywords like lext are explicitly deferred for the bootstrap phase. The rest are being filled in progressively.</p><h3>What This Unlocks</h3><p>Compile-time execution is the foundation for build-time code generation, compile-time validation, configuration baking, and eventually a full macro system that operates on real Flux ASTs rather than text substitution. The comptime VM running the same semantics as the runtime means there’s no separate “template language” to learn — it’s just Flux.</p><h3>2. Algebraic Types — Type Algebra with constraint</h3><p>Flux has always had templates. Now it has <em>relational constraints on templates</em>, which is a meaningful step up.</p><p>The constraint keyword lets you define named constraint sets that express algebraic relationships between type parameters. These constraints are then attached to template functions to restrict what combinations of types are valid at instantiation.</p><pre>constraint SafeArith(A, B)<br>{<br>    A ~= B,<br>    A !`&lt; A<br>};<br><br>def add&lt;T: int, U: int, :{SafeArith}&gt;(T x, U y) -&gt; T<br>{<br>    return x + y;<br>};</pre><h3>The Operators</h3><p>Operator Meaning ~= A and B must be compatible (same pointer depth, matching bit width) !~= A and B must be incompatible — enforces they remain distinct !@ Address-of (@) is forbidden on values of this type within the template body !`&lt; No truncation — type cannot appear in a narrowing context !`&lt;= No truncation <em>between</em> these two specific types !`&gt; No widening !`&gt;= No widening between these two specific types !-= A and B cannot participate in unsigned arithmetic together</p><p>Constraints can be written inline directly on the template parameter:</p><pre>def foo&lt;T: int, :{T !`&lt; T}&gt;(T x) -&gt; void<br>{<br>    // T can never be truncated anywhere in this function<br>};</pre><p>Or chained — the right-hand side of one relation becomes the left-hand side of the next:</p><pre>constraint Chain(A, B, C)<br>{<br>    A ~= B !~= C !`&lt; C<br>};</pre><p>That reads as three independent relations: A ~= B, B !~= C, C !&lt; C`.</p><p>You can also merge constraint sets:</p><pre>constraint Combined = MyCS1 + MyCS2;</pre><p>The merge checks for contradictions at definition time — you can’t combine ~= and !~= on the same operand pair.</p><h3>Why This Matters</h3><p>Most languages give you bounded generics at best. Flux’s type algebra lets you express things like “these two type parameters must not be able to truncate into each other,” or “this type can never have its address taken inside this template.” These constraints fire at instantiation time with precise error messages, not vague template errors deep in a call stack.</p><h3>3. Interfaces — Typed, Named, and Enforced</h3><p>Flux already had traits (behavioral contracts on objects). Interfaces build on top of them to define <em>how two objects communicate with each other</em>.</p><pre>trait Readable<br>{<br>    def read(byte*,int)-&gt;int,<br>        write(byte*,int)-&gt;int,<br>        flush()-&gt;int;<br>};<br><br>trait Writable<br>{<br>    def ack()-&gt;int;<br>};<br><br>interface Stream(A: Readable, B: Writable)<br>{<br>    A : B<br>    {<br>        read(byte*,int)-&gt;int,<br>        write(byte*,int)-&gt;int,<br>        flush()-&gt;int<br>    };<br><br>    B : A<br>    {<br>        ack()-&gt;int<br>    };<br>};</pre><p>The interface is generic — A and B are type parameters constrained by traits. The body defines which methods each side is permitted to call on the other.</p><p>You attach it to an object at the definition site:</p><pre>object Pipe<br>{<br>    ///...///<br>} : Stream(this, Socket);</pre><p>Once attached, any method call between Pipe and Socket that isn&#39;t explicitly listed in the interface is a <strong>compile-time error</strong> — even if the method is public. The interface is the contract and it is enforced statically.</p><p>If Pipe tries to use a Socket that doesn&#39;t satisfy Writable, the compiler catches it. The Socket side doesn&#39;t need to declare the interface at all — only Pipe owns it.</p><p>This is a principled answer to the “I need to formalize how these two things talk to each other” problem without runtime overhead and without ceremony on the other side of the connection.</p><h3>4. Object Inheritance</h3><p>Flux now supports object inheritance, including multiple inheritance, with rules designed to eliminate the diamond problem entirely — the compiler simply won’t let it exist.</p><pre>object A<br>{<br>    int a1, a2, a3;<br>    def __init() -&gt; this { return this; };<br>    def __exit() -&gt; void { (void)this; };<br>};<br><br>object B<br>{<br>    int b1, b2, b3;<br>    def __init() -&gt; this { return this; };<br>    def __exit() -&gt; void { (void)this; };<br>};<br><br>object C : A, B<br>{<br>    int c1, c2, c3;<br>    def __init() -&gt; this { return this; };<br>    def __exit() -&gt; void { (void)this; };<br>};</pre><p>The rules are clear and predictable:</p><ul><li>Mandatory methods (__init, __expr, __exit) are <strong>not</strong> inherited — the child always defines its own lifecycle.</li><li>If two parents define a function with matching signatures but different implementations, it’s a <strong>compile error</strong>. No silent resolution.</li><li>Private members are not inherited unless the parent explicitly grants access via private : ChildName.</li><li>A child member that already exists in the child takes precedence — the parent’s version is not inherited.</li></ul><p>You can use !+ on a parent method to mark it non-overridable:</p><pre>object B<br>{<br>    !+ def foo() -&gt; void {};<br>};<br><br>object C : B<br>{<br>    + def foo() -&gt; void {};  // Compiler error — B said no override<br>};</pre><p>The diamond problem is eliminated structurally. The rules ensure that any ambiguity in the inheritance tree is always an error, never a silent wrong answer.</p><h3>5. Type Functions — Methods on Any Type</h3><p>Type functions let you define methods directly on any type — including built-in primitives — that are called using dot notation.</p><pre>byte.clamp(byte lo, byte hi) -&gt; byte<br>{<br>    if (_ &lt; lo) { return lo; };<br>    if (_ &gt; hi) { return hi; };<br>    return _;<br>};<br><br>byte value = 200;<br>byte result = value.clamp(0, 127);</pre><p>The _ identifier is the implicit receiver inside the type function body. It cannot be redeclared. The receiver can be written as the type name itself (byte, int, float) or as the null literal of that type (false for bool, 0l for long, 0d for double).</p><p>For named struct types, use the struct name directly:</p><pre>struct Vec2<br>{<br>    float x, y;<br>};<br><br>Vec2.length() -&gt; float<br>{<br>    return sqrt(_.x * _.x + _.y * _.y);<br>};<br><br>Vec2 v {x = 3.0, y = 4.0};<br>float len = v.length();  // 5.0</pre><p>This gives you the ergonomics of method syntax on data you define — including types you don’t own. It’s not monkey-patching; it compiles down to a normal function call. The dot notation is purely syntactic.</p><h3>6. Try It Online</h3><p>Flux now has an online IDE at <a href="https://fluxspl.org/ide">https://fluxspl.org/ide</a>.</p><p>No toolchain setup. No build configuration. Write Flux, run Flux, see the output. It’s the fastest way to get your hands on the language and test out the features above.</p><h3>The Bigger Picture</h3><p>What’s interesting about this release cluster is that the features reinforce each other. Comptime execution gives you a way to validate and generate things before the binary exists. Algebraic types let you put mathematical guarantees on your generic code. Interfaces formalize object collaboration without runtime overhead. Inheritance gives you composable object hierarchies with clear, non-surprising rules. Type functions make the results of all of that genuinely pleasant to work with.</p><p>Flux has always been a language that takes a position — stack first, explicit semantics, no hidden costs. These additions keep that philosophy intact while expanding what you can express. Worth watching.</p><p><em>Flux source, documentation, and the compiler are available on GitHub. Join the </em><a href="https://discord.gg/RAHjbYuNUc"><em>Flux Discord</em></a><em> if you want to follow development or ask questions directly.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c548a3fadce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flux: The New Programming Language Built for Tomorrow’s CPUs]]></title>
            <link>https://medium.com/@karacvonthweatt/flux-the-language-built-for-tomorrows-cpus-1a8b6f87bcf7?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a8b6f87bcf7</guid>
            <category><![CDATA[hardware]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[new-programming-language]]></category>
            <category><![CDATA[flux]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Wed, 13 May 2026 17:03:41 GMT</pubDate>
            <atom:updated>2026-05-13T20:09:49.324Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ngHKB3Nb_UVBjNlBMCbhA.png" /></figure><p>As we enter an era of massive hardware innovation, the design of programming languages must evolve to keep pace with modern advancements. Flux is more than just a language, it’s the embodiment of a new paradigm in systems programming, purpose-built to leverage the architectural trajectory of modern CPUs, particularly the advent of massive cache hierarchies.</p><p>Designed with insights into how hardware is evolving, Flux stands out as the only systems programming language that fully embraces stack-by-default memory allocation, making it the fastest and most efficient language for modern performance-critical applications. Here’s why Flux is not just relevant today, but also future-proof for the next generation of CPUs.</p><h3>The Hardware Shift: CPUs Are Scaling Cache, Not Clock Speed</h3><p>For decades, performance gains in CPUs came largely from increasing clock speeds. However, as heat and power efficiency limits closed that path, CPU designers turned to:</p><p>- <strong>Multi-core processing</strong> for parallelism<br>- <strong>Out-of-order execution</strong> for smarter instruction handling, and<br>- <strong>Massive on-chip caches</strong> to reduce memory latency</p><p>Recent CPUs, such as AMD’s models with 448MB of total cache, reflect this shift towards leveraging low-latency, high-bandwidth cache hierarchies. These caches are the new performance battleground, capable of delivering data at speeds 10–20x faster than main memory (RAM).</p><p>However, most programming languages have not adapted to this evolution:</p><ul><li><strong>Heap-first architectures</strong> lead to fragmented, unpredictable memory patterns that fail to exploit the benefits of caches.</li><li><strong>Legacy languages like C and C++</strong> require manual and deliberate stack management, creating unnecessary friction for developers aiming to optimize their performance</li><li><strong>Even systems languages like Rust pay penalties</strong> due to memory safety guarantees and reliance on the heap for ownership-validation mechanisms.</li></ul><p><strong>Flux changes all of this.</strong></p><h3>The Flux Advantage: Stack-by-Default Design</h3><p><strong>Flux is the only language built from the ground up with stack allocation as the default behavior.</strong></p><p>Unlike other systems languages that encourage or allow heap-dependence unless explicitly overridden, <strong>Flux ensures that everything is allocated on the stack by default</strong>, including pointers, unless otherwise specified by the programmer.</p><p><strong>Why Stack-First Optimizations Matter:</strong></p><ol><li><strong>Faster Memory Access</strong></li></ol><ul><li>Memory allocated on the stack stays cache-resident or close to it, making it up to 20x faster than heap memory.</li><li>Heap memory, by contrast, is dynamically allocated and often ends up scattered across random regions in main memory, slowing access.</li></ul><p>2. <strong>Cache-Friendly by Design:</strong></p><ul><li>Stack allocation leverages spatial and temporal locality — data is laid out in a predictable, linear fashion, making it easy for modern CPUs to prefetch and cache efficiently.</li></ul><p>3.<strong> Zero Fragmentation:</strong></p><ul><li>The stack eliminates the challenges of heap fragmentation, ensuring predictable memory management. This simplifies programs while improving both performance and reliability.</li></ul><p>4. <strong>Minimal Runtime Overhead:</strong></p><ul><li>Stack management has virtually zero overhead since allocation and deallocation follow straightforward linear patterns. Heap management requires algorithms with non-trivial costs to handle allocation, garbage collection, or reference counting.</li></ul><h3>Competitive Edge: Why Flux Outperforms C, Rust, and Others</h3><p>With its stack-first philosophy, Flux inherently delivers predictable performance gains, even against heavyweight competitors.</p><p><strong>Flux vs C:</strong></p><ul><li>C requires explicit management: While C allows stack allocation, developers must manually ensure variables remain on the stack. Flux removes this cognitive overhead by making the stack the default.</li><li>Flux also avoids C’s reliance on the heap for constructs like dynamic pointers — critical in systems programming.</li></ul><p><strong>Flux vs Rust:</strong></p><ul><li>Rust’s borrow checker introduces runtime overhead and restricts developers to ownership-based memory models, often forcing heap usage for safety.</li><li>Flux trusts the programmer while offering opt-in ownership without unnecessary restrictions, enabling stack-first patterns that outperform Rust in cache-bound workloads.</li></ul><p><strong>Flux vs Python/Go:</strong></p><ul><li>Unlike managed languages (Python, Go), which abstract memory management entirely with heap and garbage collection, Flux gives direct control over allocation allowing it to operate in low-latency and resource-constrained environments.</li></ul><h3>Why Flux Is Future-Proof for the New CPU Era</h3><p>The trend of massive CPU caches and increasingly complex memory hierarchies solidifies Flux’s position as the language of the future. Here’s why:</p><ol><li><strong>Made for Modern Hardware:</strong></li></ol><ul><li>Modern CPUs are optimized for <strong>patterns of locality</strong>, and Flux’s stack-first design takes advantage of this by ensuring that data resides in low-latency, high-speed caches.</li></ul><p>2. <strong>Scalable Performance:</strong></p><ul><li>As CPUs integrate even larger caches, the performance gap between stack and heap usage will only grow. Flux’s focus on stack allocation guarantees that it remains the<strong> fastest option on high-end hardware.</strong></li></ul><p>3. <strong>Low Overhead for High Throughput:</strong></p><ul><li>Massive parallel systems with dozens or hundreds of cores require predictable memory behavior for lock-free, low-contention programming. Flux’s stack philosophy ensures that even in heavily threaded environments, memory contention is minimized.</li></ul><p>4. <strong>Ideal for Real-Time and Embedded Systems:</strong></p><ul><li>With its stack-first design, Flux is ready for <strong>embedded systems, IoT, edge computing, and game engines </strong>— domains where deterministic performance, low latency, and efficient use of limited resources are critical.</li></ul><p>5. <strong>Aligned with Green Computing:</strong></p><ul><li>Efficient cache usage not only improves speeds but also reduces energy consumption, making Flux a natural fit for <strong>energy-efficient software development in a resource-conscious world</strong>.</li></ul><h3><strong>The Future is Flux</strong></h3><p>Programming languages often lag behind hardware advancements, but Flux flips the equation. By aligning itself with the trajectory of <strong>cache-optimized, high-core-count CPUs</strong>, Flux redefines systems programming for the modern and future eras of computing.</p><p>Whether you’re optimizing embedded devices, building network protocols, developing game engines, or working on memory-intensive applications, Flux delivers unmatched performance with its stack-first design philosophy. It is not just a language for today — it is the <strong>future of systems programming</strong>.</p><h3>Where Can I Get Flux?</h3><p>Flux is on GitHub at <a href="https://github.com/kvthweatt/Flux">https://github.com/kvthweatt/Flux</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a8b6f87bcf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Fresh Wave: New Programming Languages Shaking Up 2026]]></title>
            <link>https://medium.com/@karacvonthweatt/the-fresh-wave-new-programming-languages-shaking-up-2026-98b15b76a8b3?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/98b15b76a8b3</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[hardware]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Wed, 29 Apr 2026 19:24:43 GMT</pubDate>
            <atom:updated>2026-04-30T14:26:49.969Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*7DCEeLKZTNcMcHQpIw4jOw.png" /><figcaption>Sublime Text editor showing Flux code</figcaption></figure><p>The programming language landscape has never been more alive. While Python, Rust, and Go continue to dominate headlines, a quieter revolution is happening underneath — a generation of new languages built not to chase trends, but to solve specific problems that existing languages handle poorly. Some are backed by major studios and corporations. Others are the work of independent developers pushing ideas forward on their own terms. All of them are worth paying attention to.</p><p>Here’s a look at the new programming languages gaining traction in 2026:</p><h3>Mojo — Python’s Faster Alter Ego</h3><p>Mojo has been in development for a few years, but 2025 and 2026 are when it started to matter. Built by Modular and designed explicitly for AI development, Mojo’s pitch is straightforward: Python syntax and ergonomics, C-level performance. It achieves this through a type system that lets you drop down to low-level memory semantics when you need to, while staying comfortable and familiar the rest of the time.</p><p>What changed recently is scale. Mojo is now installable through standard Python tooling, which dramatically lowers the barrier to entry, and GPU integration has matured to the point where serious ML engineers are using it in production workflows. For a language that wants to own the AI stack, getting into the hands of Python developers without friction is exactly the right move.</p><h3>Gleam — Functional, Safe, and Concurrent</h3><p>Gleam runs on the Erlang VM — the same runtime that powers WhatsApp, Discord, and large chunks of the telecommunications industry — and it brings something the BEAM ecosystem has long lacked: a strong static type system. Erlang and Elixir are powerful but dynamically typed, which means certain classes of bugs only surface at runtime. Gleam catches them at compile time.</p><p>It’s been gaining real traction through 2025 and into 2026 among developers who want the fault-tolerance and concurrency model of the BEAM without giving up type safety. The community is small but growing fast, and the language has a clarity to it that makes it surprisingly approachable for a functional language.</p><h3>Verse — Epic’s Bet on the Metaverse</h3><p>Verse is Epic Games’ in-house language, built for Unreal Editor for Fortnite and designed with real-time open-world game development at its core. It’s a multi-paradigm language with a heavy emphasis on something most languages don’t prioritize: long-term backward compatibility. Epic is thinking in decades here, not release cycles, because game worlds are expected to outlive the tools that built them.</p><p>It’s a narrow use case by design, but within that niche it’s doing things other languages aren’t. The concurrency model is built around the demands of live game worlds, and the guarantees around compatibility mean developers can build on it without worrying their code becomes dead weight after the next engine update.</p><h3>Hare — C, But Honest</h3><p>Hare is a systems language with a simple philosophy: do what C does, but without the footguns. No undefined behavior by design, a minimal standard library, and a focus on clarity over cleverness. It targets the same space as Zig — replacing C for low-level systems work — but with its own distinct approach to what “better” means.</p><p>It’s not trying to be Rust. There’s no borrow checker, no ownership model. It just wants to be a clean, honest systems language that a programmer can hold entirely in their head. For a certain kind of developer, that’s exactly the right answer.</p><h3>Come — Rethinking C from the Ground Up</h3><p>Come is one of the newer entries, emerging in early 2026. It takes C as its spiritual starting point but systematically removes the parts that cause the most pain — raw pointers, manual memory management, malloc and free. In their place it offers constructs like ubyte arrays and a resize() function, pushing toward safety without abandoning the low-level control that makes C useful in the first place.</p><p>It’s experimental, and that’s the point. Come is a language actively working out what a modern C replacement could look like without the weight of decades of legacy decisions. It’s worth watching.</p><h3>Flux — High-Trust Systems Programming</h3><p>Most new systems languages are defined by what they take away from you. Rust takes away memory safety errors by taking away direct control. Zig takes away hidden allocations. Hare takes away complexity. Flux takes a different position: it gives you more, and trusts you to use it correctly.</p><p>Flux is a statically typed, compiled, general-purpose language built for precise control over data. Everything is stack-allocated and zero-initialized by default. Heap allocation is opt-in via the heap keyword, not the default assumption. There&#39;s no garbage collector, no borrow checker, no runtime fighting you over ownership. The compiler&#39;s job is to compile your code, not to second-guess your intentions.</p><p>What sets Flux apart is its type system. The data primitive lets you define integer types of arbitrary bit width — data{12}, data{24}, whatever the problem demands — which makes it genuinely suited for embedded systems, network protocol parsing, binary file formats, and hardware interfaces where standard 8/16/32/64-bit types are an awkward fit. Casting a byte array directly onto a struct and reading typed fields out of it is idiomatic Flux, not a hack.</p><p>The language is C ABI compatible, targets LLVM for its backend, and has a rich operator set with a completely distinct bitwise operator family — no ambiguity between logical and bitwise operations. Custom infix operators are supported. Templates work without SFINAE. There’s a singinit storage class for program-lifetime function-scoped variables, tail-call optimization via the &lt;~ return arrow, and function chaining through the &lt;- operator. These aren&#39;t features bolted on — they&#39;re part of a consistent design that rewards developers who think in terms of data layout and control flow rather than object hierarchies.</p><p>Flux is currently at version 1.2.0 with a working compiler, a growing standard library, and tooling in active development including a package manager, LSP, and IDE. The repo is at <a href="https://github.com/kvthweatt/Flux">github.com/kvthweatt/Flux</a> and there’s a Discord community for anyone who wants to get involved early.</p><p>I created Flux because I was tired of not having the features I needed in one place.</p><h3>What This Moment Means</h3><p>What’s striking about this group of languages is how different their motivations are. Mojo wants to own AI infrastructure. Gleam wants to bring type safety to a proven runtime. Verse is building for virtual worlds. Hare and Come want to fix C. Flux is a statement about what systems programming could be.</p><p>There’s no single trend here — just a lot of smart people deciding that the languages they have aren’t quite right for the problems they’re solving, and doing something about it. That’s how the best languages have always started.</p><p>The next few years will show which of these find their audiences. But the work happening right now, in 2026, is genuinely interesting. Worth paying attention to.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98b15b76a8b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The New Language Flux is Moving In!]]></title>
            <link>https://medium.com/@karacvonthweatt/flux-is-moving-in-9d3bfadef5d3?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d3bfadef5d3</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[new-programming-language]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Fri, 10 Apr 2026 21:41:08 GMT</pubDate>
            <atom:updated>2026-07-14T21:17:17.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Ownership and tracking of moving memory is important to many programmers, especially in environments where memory leaks are unacceptable. Life on the stack is easy, organized, and fast with free garbage collection, but the heap gets messy faster. Knowing memory has fully moved and all previous references invalidated is important to guaranteeing one does not access garbage memory values.</p><p>The tie operator ~ fixes this, instructing the compiler to follow a few simple rules.</p><h4>1. A tied value requires it to be untied when used.</h4><h4>2. A tied value can only move to a tied type</h4><h4>3. One-time use, old reference invalidated when used</h4><p><strong>Example 1:</strong></p><pre>#import &lt;standard.fx&gt;;<br><br>def foo(~int z) -&gt; void  // accepts a tied type<br>{<br>    return;<br>};<br><br>def main() -&gt; int<br>{<br>    ~int x;    // Read as &quot;tied int x<br><br>    foo(~x);   // Untie from main, tie to foo(), legal<br><br>    x += 5;    // Use After Untie (UAU) or &quot;wow&quot; error.<br>    <br>    return 0;<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAsNKjLn5SLMXvPdi79QGg.png" /></figure><p>After untying x from main, it is no longer a valid symbol at compile time. You must re-declare x as a new variable and allocate new memory.</p><p>Example 2:</p><pre>#import &lt;standard.fx&gt;;<br><br>def foo(~int z) -&gt; void<br>{<br>    return;<br>};<br><br>def main() -&gt; int<br>{<br>    ~int x, y; // Tied vars<br>    int  z;    // Non-tied var<br><br>    foo(z);    // Compile error, foo expects tied param<br>    foo(~z);   // Legal, invalidates z in main()<br><br>    return 0;<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLkklZY1HTr_EbhY_I5omw.png" /></figure><p>Above we see an example of the separation of tied and non-tied types. You must pass z as ~z to invalidate z in main and satisfy the function signature.</p><p>Example 3:</p><pre>#import &lt;standard.fx&gt;;<br><br>def bar(~int y) -&gt; ~int<br>{<br>    return ~y;<br>};<br><br>def main() -&gt; int<br>{<br>    ~int x, y;<br>    int  z;<br><br>    z = bar(~y);  // Copmile error, function returns tied type to non-tied type<br>    x = bar(~y);  // Legal, x is a tied type<br>    return 0;<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xJ6gQozkf1mFfBanq1UPPg.png" /></figure><p>The final separation, z simply cannot accept a return value from bar() because z&#39;s type is non-tied, and cannot accept the explicit move.</p><p>Example 4:</p><pre>#import &lt;standard.fx&gt;;<br><br>def bar(~int y) -&gt; ~int<br>{<br>    return ~y;<br>};<br><br>def main() -&gt; int<br>{<br>    ~int x, y, z;<br>    int  w = 5;<br><br>    x = bar(~y);<br><br>    z = w;   // Illegal, must explicitly transfer with ~w<br><br>    return 0;<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aDxV_GNPf0t1KUrnXuwv8g.png" /></figure><p>Example 5:</p><pre>#import &lt;standard.fx&gt;;<br><br>def bar(~int y) -&gt; ~int<br>{<br>    return ~y;<br>};<br><br>def main() -&gt; int<br>{<br>    ~int x, y, z;<br>    int  w = 5;<br><br>    x = bar(~y);<br><br>    z = ~w;<br><br>    w = 10;  // Compile error, w invalidated, must redeclare<br><br>    return 0;<br>};</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMKRIGT6e8CQRxRO4IOQIw.png" /></figure><p>You can <a href="https://github.com/kvthweatt/Flux">get Flux on GitHub</a> and try it yourself!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d3bfadef5d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flux — A New Systems Language]]></title>
            <link>https://medium.com/@karacvonthweatt/flux-a-new-systems-language-6351583a3c64?source=rss-f04f0e334dc5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6351583a3c64</guid>
            <category><![CDATA[news]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[new-programming-language]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Karac Von Thweatt]]></dc:creator>
            <pubDate>Thu, 09 Apr 2026 16:04:57 GMT</pubDate>
            <atom:updated>2026-07-14T21:16:30.094Z</atom:updated>
            <content:encoded><![CDATA[<pre>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br><br>def main() -&gt; int<br>{<br>    print(&quot;Hello World!&quot;);<br>    return 0;<br>};</pre><h3>What is Flux?</h3><p>Flux is a new language that combines the performance and power of C with the readability of Python. Flux resembles the C-family of languages, and is neither C, nor a derivative of C. It has a fundamentally different type system while still being C ABI compatible.</p><p>Characteristics:</p><ul><li>Arbitrary bit width type system with endianness baked in</li><li>First class data manipulation features</li><li>Consistent grammar and syntax constructs throughout</li><li>Rich operator collection with distinct bitwise set</li><li>Everything stack allocated and zero-initialized unless otherwise specified</li></ul><h3>Why use Flux?</h3><p>Flux is well-suited for:</p><ul><li>Embedded systems — Direct hardware register access</li><li>Network protocols — Zero-copy packet parsing</li><li>File format handling — Binary data interpretation</li><li>Game engines — Memory-efficient entity systems</li><li>Device drivers — Memory-mapped I/O</li><li>Performance-critical code — When you need C-level control</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*zABOegSFHeJEJgiWEPkt2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FGRZXMLs-raGlXpDZduUPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SdsOhjIezss8u2eCPCGtsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ab65cUBhW8LafCS-mjRtjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ROSlEvhV62CEwIe2yQzag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILVexH2M52xaiS_-RO5T7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qtof7pE5BflaE0lRKfX7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9qWo6F4VSM2lzKCh3CIo9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XG8zgJGy6ooQaf_YSAvQjg.png" /><figcaption>Mandelbrot Set rendered with Flux using OpenGL</figcaption></figure><p>Flux comes with batteries, the standard library currently includes (but is not limited to) big integer math, arbitrary precision floating point math, cryptography algorithms including MD5, SHA256/384, AES-128/GCM, and x25519. Other algorithms like ECDSA, and RSA are currently under development and still being tested for proper functionality. There is even a high-performance JSON parser available!</p><p>One feature that stands out the most is Flux’s ability to take bit slices from values. Here are a few examples:</p><pre>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br><br>struct myStru<br>{<br>    int a, b;          // Fields align as if int a; int b; was written.<br>};<br><br>def main() -&gt; int<br>{<br>    myStru x = {5,10};<br><br>    data{4} as u4;     // Custom 4 bit wide unsigned integer type<br>    u4 a = x[59``63];<br><br>    println(int(a));     // 0b1010<br>    return 0;<br>};</pre><p>And an example of reversing bits:</p><pre>#import &lt;standard.fx&gt;;<br><br>using standard::io::console;<br><br>def main() -&gt; int<br>{<br>    byte x = 55;<br><br>    x[0``7] = x[7``0];<br><br>    println(int(x));<br><br>    return 0;<br>};</pre><p>You can get Flux by visiting the official GitHub repo at <a href="https://github.com/kvthweatt/FluxLang">https://github.com/kvthweatt/Flux</a></p><p>Alternatively, there is a Flux organization which hosts a second mirror at <a href="https://github.com/FluxSysLang/Flux">https://github.com/FluxSysLang/Flux</a></p><p>The Flux official website is currently hosted on uttcex.net at <a href="https://uttcex.net/flux">https://uttcex.net/flux</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6351583a3c64" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>