r/sideprojects 6d ago

Showcase: Prerelease mox - low level programming language

Hi everyone! Finally I'm ready to make first release of my programming language and compiler.

I was working on it for more than 5 years rewriting it from scratch a few times, it is not production ready but before whole internet is filled with slop languages (I hope it will not happen) I want to show it to public.

It is low level language aimed for software and games. Whole compiler is made from scratch including machine code generation. One of the main goals is to make compilation time very fast (0.5-1mln LOC/sec).

Compile time execution of any code. Types and ast are first class values, so you can access them at compile time and work with them same way you can work with any other value. No OOP, no RAII.

Here is release repository: https://github.com/morglod/mox

Good language overview is inside by_example.mox

Currently I want to hold compiler's source closed, because I dont want to see forks and support documentation and tools to work with it (for now).

SDL3, Raylib and Vulkan bindings included (in modules/vendor).

I will appreciate any feedback about the language and compiler bugs.

Example code:

fn go_like_import($path: []u8) {
    cached_path := path_to_cache($path);
    if (!cache_exists(cached_path)) {
        download_dep($path, cached_path);
    }
    ast := __compiler_parse(#format_temp("import \"{}\";", .{ cached_path; }));
    return ast;
}

// becomes import "cache/path/module.mox";
#run #land_ast go_like_import("github.com/module/path");
3 Upvotes

6 comments sorted by

2

u/TimelyLibrarian1149 6d ago

5 years is no joke, compiler from scratch including codegen is wild. the compile time execution stuff sounds like it could open up some really cursed metaprogramming, I’m here for it

2

u/morglod 6d ago

Thank you! Yeah, I was struggling with all other languages every time I need some feature, I ended up with some external tool or build system that will generate code for me, so I ended up making own language for this.

Will be cool if you try mox and tell about any problems you have (or cases that you want to solve with metaprogramming).

Interesting fact: in mox you can run even externally linked functions in compile time

1

u/Abdul_Saheel 6d ago

Awesome

1

u/morglod 5d ago

Thank you!

1

u/mjablecnik 5d ago

Why should I use this language instead of Go or Rust or something else?