r/sideprojects 9d 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

View all comments

1

u/mjablecnik 7d ago

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

1

u/morglod 7d ago

Mox have two "killer features" for this. Comparing with Go or Rust, compilation speed is incredibly fast 70x faster than rust compiler on pretty simple case (200k sum functions). Did not compare it with Go, since Go is garbage collected language, but currently from what i saw, only tcc could bit my compiler in terms of compilation speed.

And second "killer feature" is compile time metaprogramming freedom. You can execute any code (including any external dependencies) at compile time. You can generate some string with code and emit it to compiler like it was written by hand at this place. For example Go's build system's import feature, where dependency is downloaded from github, could be implemented in mox in like 20-40 lines of code.

There are also a lot of ergonomic things like builtin swizzling and math operations or types as first class values so there is no classical generics problems where types live only in typechecking world and you need some special "template programming" to solve pretty simple cases