Coding Global Background
Coding Global

Flux - My new programming language

0 Nachrichten
1 Mitglieder
Erstellt 3 hours ago
Aktualisiert 3 hours ago
In Discord öffnen
O
Hylyx

Spielt Custom Status

Verified
Flux is a compiled systems language, designed to have the power and low level control of C, with the readability and expressiveness of Python.

https://github.com/kvthweatt/FluxLang

Here's an example of taking a bit slice out of a struct:
#import "standard.fx";

using standard::io::console;

struct xx { int a, b; };

def main() -> int
{
    data{4} as u4;
    xx yy = {5,10};
    u4 a = yy[59``63]; // last 4 bits of struct, 10 because 0b1010

    print((int)a);

    return 0;
};


And here's reversing bits:
#import "standard.fx";

using standard::io::console;

def main() -> int
{
    byte x = 55;

    x[0``7] = x[7``0];

    println(int(x));

    return 0;
};


You can take bit slices of bit slices as well.


Flux has seamless FFI with C, everything is stack allocated by default including pointers, and everything is zero initialized by default. You can opt-in to uninitialized declaration like:
int x = noinit;

You can also assign arbitrary bytes to a function pointer, and if its valid machine code for your arch, you can execute that function. Example:
#import "standard.fx";

using standard::io::console;

def main() -> int
{
    byte[] some_bytecode = [0x48, 0x31, 0xC0, 0xC3];  // xor rax,rax ; ret
    def{}* fp()->void = @some_bytecode;
    fp();
    
    return 0;
};


Looking forward to feedback!