<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Karac Thweatt</title>
    <description>The latest articles on DEV Community by Karac Thweatt (@kvthweatt).</description>
    <link>https://dev.to/kvthweatt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3901205%2F29c89d83-b41a-42e3-abad-8f671872dc61.jpg</url>
      <title>DEV Community: Karac Thweatt</title>
      <link>https://dev.to/kvthweatt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kvthweatt"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Karac Thweatt</dc:creator>
      <pubDate>Mon, 27 Apr 2026 21:23:35 +0000</pubDate>
      <link>https://dev.to/kvthweatt/-44a8</link>
      <guid>https://dev.to/kvthweatt/-44a8</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p" class="crayons-story__hidden-navigation-link"&gt;Flux - the new programming language is built for speed, easy to read, and familiar.&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/kvthweatt" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3901205%2F29c89d83-b41a-42e3-abad-8f671872dc61.jpg" alt="kvthweatt profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/kvthweatt" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Karac Thweatt
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Karac Thweatt
                
              
              &lt;div id="story-author-preview-content-3559140" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/kvthweatt" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3901205%2F29c89d83-b41a-42e3-abad-8f671872dc61.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Karac Thweatt&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Apr 27&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p" id="article-link-3559140"&gt;
          Flux - the new programming language is built for speed, easy to read, and familiar.
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/programming"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;programming&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/languages"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;languages&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/compilers"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;compilers&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/new"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;new&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt; reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            6 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Flux - the new programming language is built for speed, easy to read, and familiar.</title>
      <dc:creator>Karac Thweatt</dc:creator>
      <pubDate>Mon, 27 Apr 2026 21:20:55 +0000</pubDate>
      <link>https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p</link>
      <guid>https://dev.to/kvthweatt/flux-the-new-programming-language-built-for-speed-easy-to-read-and-familiar-378p</guid>
      <description>&lt;p&gt;I've been working on Flux - my new compiled, general-purpose systems programming language - and wanted to write up what it looks like today. This isn't a roadmap post or a vision doc, just a walkthrough of the language as it exists right now. Source files use the &lt;code&gt;.fx&lt;/code&gt; extension, the compiler targets LLVM, and the language is nearing bootstrap.&lt;/p&gt;

&lt;p&gt;First things first. Flux is not C, nor a C derivative / wrapper.&lt;/p&gt;

&lt;p&gt;Let's start simple and build up from there.&lt;/p&gt;




&lt;h2&gt;
  
  
  Hello, World
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#import "standard.fx";

using standard::io::console;

def main() -&amp;gt; int
{
    print("Hello, World!\n");
    return 0;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to notice immediately: &lt;code&gt;def&lt;/code&gt; is the function keyword, &lt;code&gt;-&amp;gt;&lt;/code&gt; declares the return type, and the closing brace of a compound statement gets a semicolon - compound statements are terminated just like any other statement in Flux. It's consistent everywhere once you internalize it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#import&lt;/code&gt; is textual - it splices the file contents at the import site. Multiple imports are processed left to right:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#import "standard.fx";
#import "mylib.fx", "foobar.fx";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;using&lt;/code&gt; declaration brings a namespace into scope. Namespaces use &lt;code&gt;::&lt;/code&gt; for access, and duplicate namespace definitions merge rather than conflict - a library can spread a namespace across multiple files and it behaves as one namespace at the use site.&lt;/p&gt;




&lt;h2&gt;
  
  
  Variables and Primitives
&lt;/h2&gt;

&lt;p&gt;Flux has the types you'd expect for systems work:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;bool&lt;/code&gt;, &lt;code&gt;byte&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;uint&lt;/code&gt;, &lt;code&gt;long&lt;/code&gt;, &lt;code&gt;ulong&lt;/code&gt;, &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;double&lt;/code&gt;, &lt;code&gt;char&lt;/code&gt;, &lt;code&gt;void&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And one you might not: &lt;code&gt;data&lt;/code&gt;. More on that shortly.&lt;/p&gt;

&lt;p&gt;Variables are stack-allocated by default. Heap allocation requires the &lt;code&gt;heap&lt;/code&gt; keyword - there's no implicit dynamic allocation anywhere.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int x = 5;
uint y = 300u;
float pi = 3.14159;
bool flag = true;

heap string s = "some data";
(void)s;   // explicit cleanup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Multiple declarations can be comma-chained:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int x = 10,
    y = 20,
    z = y - x; // declared in order, so this works
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;void&lt;/code&gt; as a value equals &lt;code&gt;0&lt;/code&gt; equals &lt;code&gt;false&lt;/code&gt;. You can use it directly in expressions and comparisons, and it serves as the null value for pointers.&lt;/p&gt;




&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;Functions live at module, namespace, or object scope - no nested function definitions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def myAdd(int x, int y) -&amp;gt; int
{
    return x + y;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overloading works on type signature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def myAdd(float x, float y) -&amp;gt; float
{
    return x + y;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prototypes (forward declarations) don't require parameter names, only types:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def myAdd(int, int) -&amp;gt; int,
    myAdd(float, float) -&amp;gt; float;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;def&lt;/code&gt; is &lt;code&gt;fastcall&lt;/code&gt; by default. Other calling conventions are first-class keywords like &lt;code&gt;stdcall&lt;/code&gt;, &lt;code&gt;cdecl&lt;/code&gt;, &lt;code&gt;vectorcall&lt;/code&gt;, and &lt;code&gt;thiscall&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Control Flow
&lt;/h2&gt;

&lt;p&gt;Standard &lt;code&gt;if&lt;/code&gt;/&lt;code&gt;elif&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, &lt;code&gt;do&lt;/code&gt;/&lt;code&gt;while&lt;/code&gt;, and &lt;code&gt;switch&lt;/code&gt; - all terminated with semicolons. &lt;code&gt;switch&lt;/code&gt; only puts the semicolon on the &lt;code&gt;default&lt;/code&gt; block. &lt;code&gt;try&lt;/code&gt;/&lt;code&gt;catch&lt;/code&gt; only puts it on the last catch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (int i = 0; i &amp;lt; 10; i++)
{
    if (i % 2 == 0) { continue; };
    print(f"{i}");
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ternary works as expected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int z = x &amp;lt; y ? y : 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Flux also has a null-coalesce operator &lt;code&gt;??&lt;/code&gt; and a conditional assign &lt;code&gt;?=&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int z = y ?? 0;    // z = y if y is non-null, else 0
x ?= 50;           // assign 50 only if x is currently null/zero
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Structs
&lt;/h2&gt;

&lt;p&gt;Structs are always packed - no compiler-inserted padding. You control alignment by choosing your types. They're non-executable: no functions, no objects, just data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct xyzStruct
{
    int x, y, z;
};

xyzStruct v {x = 1, y = 2, z = 3};
print(v.x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structs can contain other structs, support composition (prepend/append another struct's fields), and can be templated:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct Pair&amp;lt;A, B&amp;gt;
{
    A first;
    B second;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Template arguments are inferred at the call site.&lt;/p&gt;




&lt;h2&gt;
  
  
  Objects
&lt;/h2&gt;

&lt;p&gt;Objects are executable types with constructors, destructors, and methods. &lt;code&gt;this&lt;/code&gt; is always implicit - never a parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;object Counter
{
    int val;

    def __init(int start) -&amp;gt; this
    {
        this.val = start;
        return this;
    };

    def __exit() -&amp;gt; void {};

    def increment() -&amp;gt; void
    {
        this.val++;
    };
};

Counter c = 0;       // sugar for Counter c(0);
c.increment();
print(c.val);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Single-parameter &lt;code&gt;__init&lt;/code&gt; allows the assignment-style instantiation shown above.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;defer&lt;/code&gt; runs cleanup in LIFO order, immediately before the function returns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Counter c = 0;
defer c.__exit();
// ... c is cleaned up automatically at return
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Traits&lt;/strong&gt; enforce structural contracts at compile time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;trait Drawable
{
    def draw() -&amp;gt; void;
};

Drawable object Sprite
{
    def draw() -&amp;gt; void
    {
        // must not be empty
        return void;
    };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a &lt;code&gt;Drawable&lt;/code&gt; object doesn't implement &lt;code&gt;draw()&lt;/code&gt;, compilation fails.&lt;/p&gt;




&lt;h2&gt;
  
  
  Error Handling
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;throw&lt;/code&gt; accepts any type. &lt;code&gt;catch&lt;/code&gt; matches by type, with &lt;code&gt;auto&lt;/code&gt; as the catch-all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def risky(int mode) -&amp;gt; void
{
    if (mode == 1) { throw(ErrorA(100)); }
    elif (mode == 2) { throw(ErrorB("failed")); }
    else { throw("generic"); };
};

try
{
    risky(2);
}
catch (ErrorA e) { print(f"code: {e.code}"); }
catch (ErrorB e) { print(f"msg: {e.message}"); }
catch (string s) { print(s); }
catch (auto x)   { print("unknown"); };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Memory and Pointers
&lt;/h2&gt;

&lt;p&gt;Heap allocation goes through &lt;code&gt;fmalloc&lt;/code&gt; and &lt;code&gt;ffree&lt;/code&gt; directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;u64 p = fmalloc(sz);
if (!(@)p) { ok = false; break; };
total_bytes += (i64)sz;
ffree(p);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;@&lt;/code&gt; is address-of. &lt;code&gt;(@)&lt;/code&gt; is an address cast - converts an integer value to a pointer. &lt;code&gt;!&lt;/code&gt; applied to a pointer emits a null check. There's also a postfix not-null operator &lt;code&gt;!?&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (ptr!?) { /* ptr is non-null */ };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pointer arithmetic, casting, and raw dereferencing all work as you'd expect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;byte* bp = (byte*)@addr;
int val = *some_ptr;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The &lt;code&gt;data&lt;/code&gt; Type and Bit-Level Work
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;data{N}&lt;/code&gt; declares N-bit raw storage, unsigned by default. You can apply &lt;code&gt;signed&lt;/code&gt; and create type aliases with &lt;code&gt;as&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;signed data{32} as fixed16_16;

def to_fixed(float value) -&amp;gt; fixed16_16
{
    return (fixed16_16)(value * 65536.0);
};

def fixed_mul(fixed16_16 a, fixed16_16 b) -&amp;gt; fixed16_16
{
    i64 temp = ((i64)a * (i64)b) &amp;gt;&amp;gt; 16;
    return (fixed16_16)temp;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Flux also has endian-aware width types as first-class aliases: &lt;code&gt;nybble&lt;/code&gt;, &lt;code&gt;be16&lt;/code&gt;, &lt;code&gt;be32&lt;/code&gt;, &lt;code&gt;be64&lt;/code&gt;, &lt;code&gt;le16&lt;/code&gt;, &lt;code&gt;le32&lt;/code&gt;, and so on. Network and binary protocol structs look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct IPHeader
{
    nybble version, ihl;
    byte tos;
    be16 total_length, identification, flags_offset;
    byte ttl, protocol;
    be16 checksum;
    be32 src_addr, dst_addr;
};

def parse_ip(byte* packet) -&amp;gt; IPHeader
{
    IPHeader* header = (IPHeader*)packet;
    return *header;
};

def format_ip(be32 addr) -&amp;gt; string
{
    byte* bp = (byte*)@addr;
    return f"{bp[0]}.{bp[1]}.{bp[2]}.{bp[3]}";
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Operators
&lt;/h2&gt;

&lt;p&gt;Flux separates logical and bitwise operators syntactically. Logical: &lt;code&gt;&amp;amp;&lt;/code&gt;, &lt;code&gt;|&lt;/code&gt;, &lt;code&gt;^^&lt;/code&gt; (XOR), &lt;code&gt;!&amp;amp;&lt;/code&gt; (NAND), &lt;code&gt;!|&lt;/code&gt; (NOR). Bitwise versions are prefixed with a backtick: &lt;code&gt;`&amp;amp;&lt;/code&gt;, &lt;code&gt;`|&lt;/code&gt;, &lt;code&gt;`^^&lt;/code&gt;, &lt;code&gt;`!&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Shifts: &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt;, &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;.&lt;br&gt;
Bit slice (extracts a range of bits):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a[x``y]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Operator overloading is supported as long as at least one parameter is not a built-in primitive - &lt;code&gt;struct&lt;/code&gt; and &lt;code&gt;object&lt;/code&gt; types are always eligible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def operator+(xyzStruct a, xyzStruct b) -&amp;gt; xyzStruct
{
    return xyzStruct {x = a.x + b.x, y = a.y + b.y, z = a.z + b.z};
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Templates and contracts can be attached to operator definitions.&lt;/p&gt;

&lt;p&gt;The chain operator &lt;code&gt;&amp;lt;-&lt;/code&gt; passes the right-hand result as the first argument to the left-hand function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int z = foo() &amp;lt;- bar();   // == foo(bar())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And &lt;code&gt;&amp;lt;~&lt;/code&gt; on a function declaration emits &lt;code&gt;musttail&lt;/code&gt;, guaranteeing zero stack growth for tail-recursive functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def trampoline(int n) &amp;lt;~ int;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Contracts and Macros
&lt;/h2&gt;

&lt;p&gt;Contracts are pre/post conditions attached to functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;contract positive { assert(x &amp;gt; 0, "x must be greater than zero"); };

def sqrt_int(int x) -&amp;gt; int : positive
{
    // x is guaranteed &amp;gt; 0 here
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Parameterized contracts match the arity of the function they're attached to.&lt;/p&gt;

&lt;p&gt;Macros are expression-only and expand at the call site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;macro CLAMP(val, lo, hi)
{
    (val, lo, hi) ((val) &amp;lt; (lo) ? (lo) : (val) &amp;gt; (hi) ? (hi) : (val))
};
int c = CLAMP(x, 0, 255);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Macros and contracts can be mixed on the same function.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enums, Unions, and the Preprocessor
&lt;/h2&gt;

&lt;p&gt;Enums are typed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enum Color { Red, Green, Blue };

Color c = Color::Red;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unions share memory across members in the usual way, declared like structs.&lt;/p&gt;

&lt;p&gt;The preprocessor is minimal: &lt;code&gt;#import&lt;/code&gt;, &lt;code&gt;#dir&lt;/code&gt;, &lt;code&gt;#def&lt;/code&gt;, &lt;code&gt;#ifdef&lt;/code&gt;, &lt;code&gt;#ifndef&lt;/code&gt;, &lt;code&gt;#else&lt;/code&gt;, &lt;code&gt;#warn&lt;/code&gt;, &lt;code&gt;#stop&lt;/code&gt;. &lt;code&gt;#dir&lt;/code&gt; adds a path to the search list. &lt;code&gt;#stop&lt;/code&gt; hard-halts compilation with a message.&lt;/p&gt;




&lt;h2&gt;
  
  
  Putting It Together:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#import "standard.fx";

using standard::io::console;

struct myStru&amp;lt;T&amp;gt;
{
    T a, b;
};

def foo&amp;lt;T, U&amp;gt;(T a, U b) -&amp;gt; U
{
    return a.a * b;
};

def bar(myStru&amp;lt;int&amp;gt; a, int b) -&amp;gt; int
{
    return foo(a, 3);
};

macro macNZ(x)
{
    x != 0
};

contract ctNonZero(a,b)
{
    assert(macNZ(a), "a must be nonzero");
    assert(macNZ(b), "b must be nonzero");
};

contract ctGreaterThanZero(a,b)
{
    assert(a &amp;gt; 0, "a must be greater than zero");
    assert(b &amp;gt; 0, "b must be greater than zero");
};

operator&amp;lt;T, K&amp;gt; (T t, K k)[+] -&amp;gt; int
:     ctNonZero(  c,   d), // works on arity and position, not identifier name.
ctGreaterThanZero(e,   f)
{
    return t + k;
};

def main() -&amp;gt; int
{
    myStru&amp;lt;int&amp;gt; ms = {10,20};

    int x = foo(ms, 3);

    i32 y = bar(ms, 3);

    println(x + y);

    return 0;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Current State
&lt;/h2&gt;

&lt;p&gt;The standard library is actively growing - JSON, UUIDs, networking, hashing, and encryption are all in progress. Bootstrapping - rewriting the compiler in Flux - is the next major milestone. There's a GitHub repository, Discord server, and website if you want to follow along or get involved.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/kvthweatt/Flux" rel="noopener noreferrer"&gt;https://github.com/kvthweatt/Flux&lt;/a&gt;&lt;br&gt;
Discord: &lt;a href="//discord.gg/wVAm2E6ymf"&gt;discord.gg/wVAm2E6ymf&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>languages</category>
      <category>compilers</category>
      <category>new</category>
    </item>
  </channel>
</rss>
