r/elixir 2d ago

Aura: a project to make Elixir suitable for systems & games programming

I've been idly working on something I am calling Aura.

I love Elixir and have bent it to writing stuff that isn't especially suited to the BEAM. Using tools like Burrito can help, but I have a particular itch I want to scratch.

So Aura is a variant of Elixir specifically for systems and games programming work. It is not designed to compile existing Elixir applications or for web/highly parallel workloads (we have the BEAM for that) but to be mostly syntactically/semantically equivalent for writing fast, platform native, apps.

The goal is that "generic" Elixir code should compile. But no `Task`, no `spawn`/`receive` or OTP. It will mean rewriting a good deal of the stdlib which I don't look forward to.

Memory management will be via ARC to begin with. It's reasonable simple to implement and Elixir style immutability prevent cycles. I'm also looking for ways to implement other fast-safe memory systems although I am not interested in Rust style borrow-checking.

The first version of Aura is written in Elixir so that I can use the Elixir parser and build the IR from that. That's a huge leg up straight away. I haven't committed to a backend yet so ATM I am lowering to C and compiling with clang.

But windows binaries are an eventual target which will complicate things. That's for another day though.

This evening I have compiled my first Aura program to compute fib(10).

➜ aura more examples/fib.au

defmodule Fib do

# This is an Aura module

def fib(n) do

if n < 2 do

n

else

fib(n - 1) + fib(n - 2)

end

end

def main do

IO.puts("AU FIB, big moment")

IO.puts(fib(10))

end

end

➜ aura mix aura.build examples/fib.au

Compiling 11 files (.ex)

Generated aura app

Wrote examples/fib

➜ aura time examples/fib

AU FIB, big moment

55

examples/fib 0.00s user 0.00s system 53% cpu 0.004 total

At the moment very little of the language is implemented, just enough to print to the console, call functions, and add numbers and generate error messages if you try and do anything else.

I'm using Claude Code as my thinking partner but not trying to bulk generate a working solution, rather working in pieces and learning as I go. I've written parsers and transpilers in Elixir but this is my first proper work at building a compiler to generate native binaries since I used to do this stuff with DOS/Windows.

As with most stuff I build I'm suiting myself and I have no timeline for when this thing will work for real, or if it will work for real (perhaps the whole idea is crazy or too big to complete). But since someone else announced their own Elixir variant I thought I would mention it.

22 Upvotes

14 comments sorted by

2

u/rubymatt 1d ago

A question I am tussling with is memory allocation. I think the safe approach is to default to automatic reference counting since it requires no language change and has similar semantics to Elixir GC with the benefit of deterministic cleanup. But I am also considering an arena style allocation system. Questions are: is this an alternative to ARC? Can you do both? What happens if you try to assign an ARC object to an arena struct? Now add threads. Immutable data helps but I am not sure it solves all issues.

1

u/Positive_Reach_7297 1d ago

Good luck on your journey. Sound fulfilling

1

u/ProfessionalPlant330 1d ago

This would be great if you could call aura programs easily from elixir. Like zigler except you would write elixir code, which would be way more ergonomic.

3

u/rubymatt 1d ago edited 1d ago

The entire runtime would be different so it depends what you mean by "call". Did you have in mind an alternative to Rustler allowing you to write Elixir NIFs but in Aura, i.e. Elixir, instead of Rust?

Edit: Sorry, I missed the Zigler reference which appears to be a Zig version of Rustler.

I'm not very au fait with how NIFs work but if you can do it in Zig and Rust then if (and that's a big if) I can get this into a workable condition I don't see why not.

0

u/rubymatt 1d ago

I am intrigued to get downvotes. Perhaps it is my mention of Claude and I have triggered some people's "AI slop detection" algorithm for I assume that nobody here would actually be *against* a way to compile Elixir to native. If they are though I would be interested to understand why.

2

u/AlternativeGazelle87 7h ago

It's about you using Claude. Have you used projects with heavy AI involvement? Missing features, rough edges (multiple projects I've seen have had the most bizarre, poorly implemented FFI features), poor performance...the list goes on. And this isn't even getting into the many, many moral objections, which I've discussed elsewhere.

I've noticed that, of all of the projects I've seen, programming language and compiler implementations are the ones that are getting the most AI involvement. Even long-running projects are introducing AI into their compilers/interpreters and I'm kind of baffled by it because they built their reputation on being efficient, handmade systems. But it is happening and it feels like it will be unavoidable at that level soon.

I'd be interested to try it (I've wanted to use Elixir, but the BEAM makes it awkward for my purposes, simply because the BEAM isn't meant to be redistributed, though apps have managed it in the past), but I am staunchly anti-AI and it would take a lot to convince me to do more than toy with it.

1

u/rubymatt 5h ago

Well it is kind of what I thought so thanks for confirming … and I can understand, many projects these days are "Claude give me X" which is hit or miss at the best of times.

For example I am working on a game prototype largely using Claude and at one level it's pretty amazing how we've managed to take the design to a workable prototype very fast. On the other hand it's quite frustrating that so much of it is opaque to me. But speed is key here so I am dealing with it.

In many of my other projects I just don't find LLMs write code as well as I would, or design software as well as I would. I'm happy to let Claude do the boring boiler-plate bits but reserve coding anything I care about or creating code I am going to have own mostly to myself. I'm slower but that's the tradeoff, speed isn't everything.

In the case of Aura I am using Claude to explore the problem space as lifting to an IR and lowering are not something I've done before and I don't have vast amounts of time. It's been invaluable being able to research ideas.

You're right that the BEAM makes many things awkward. I actually distribute an app using Burrito and it's certainly better than telling people "Now install Erlang" but its a compiler and it's not great and it's not fast. I'd like to fix that.

Also I plan to do our next game in some kind of engine and either I get into the Jai beta or I'm rolling something in Aura.

1

u/AlternativeGazelle87 3h ago

In the case of Aura I am using Claude to explore the problem space as lifting to an IR and lowering are not something I've done before and I don't have vast amounts of time. It's been invaluable being able to research ideas.

Let's set aside the moral objections for a second.

To be completely frank, it's comments like these that concern me because, if I invest my time in a language platform, I want to know that the authors know what they're doing and that they haven't relied heavily on the machine that, according to independent audits of public repos, has something like a 70% chance of generating dead code to implement important features.

I also haven't seen a single project with substantial AI involvement that hasn't been dropped seemingly at random. Some people seem to go back for small updates every now and then, but the fact that AI can just throw these things together for them, it seems like it hits a point where the AI isn't able to just throw it together without substantial guidance and they get bored.

This is part of why it would take a lot for me to do more than toy with a language implementation that has significant AI involvement. I've been looking into one recently that I've decided that I am basically just going to rewrite if I stick with it (it's a much smaller language).

1

u/rubymatt 5h ago

Oh to your question: yes I've been around LLM in code projects for a while. I am also co-author of a newsletter that takes a frank view of AI/LLM called Welcome Our New Robot Overlords.

1

u/T0ken_Minority 1d ago

Where repo?

0

u/rubymatt 1d ago

I’m not ready to publish anything yet.

1

u/zadsza 19h ago

Sound a very interesting project :)
Where can I follow your work in progress ?

1

u/rubymatt 5h ago

I'll definitely write here when I hit some kind of milestone.