Home

Awesome

Alumina Programming Language

Alumina is an imperative, general-purpose, statically typed, compiled system programming language.

Non-exhaustive list of distinguishing features:

Alumina is heavily inspired by Rust, especially in terms of syntax and standard library API. Unlike Rust, however, Alumina is not memory-safe and it requires manual memory management.

Quick links

Motivating example

<!-- github, add syntax highlighting for Alumina pls -->
struct Stack<T> {
   data: &mut [T],
   len: usize,
}

impl Stack<T> {
   use std::mem::slice;

   fn new() -> Stack<T> {
      with_capacity(0)
   }

   fn with_capacity(capacity: usize) -> Stack<T> {
      Stack {
         data: slice::alloc(capacity),
         len: 0,
      }
   }

   fn reserve(self: &mut Stack<T>, additional: usize) {
      use std::cmp::max;

      if self.len + additional > self.data.len() {
         self.data = self.data.realloc(max(
            self.data.len() * 2,
            self.len + additional
         ));
      }
   }

   fn push(self: &mut Stack<T>, value: T) {
      self.reserve(1);
      self.data[self.len] = value;
      self.len += 1;
   }

   fn pop(self: &mut Stack<T>) -> T {
      self.len -= 1;
      self.data[self.len]
   }

   fn is_empty(self: &Stack<T>) -> bool {
      self.len == 0
   }

   fn free(self: &mut Stack<T>) {
      self.data.free();
   }
}

fn main() {
   let v: Stack<&[u8]> = Stack::new();
   defer v.free();

   v.push("Stack.\n");
   v.push("a ");
   v.push("am ");
   v.push("I ");

   while !v.is_empty() {
       print!("{}", v.pop());
   }
}

Status

Bootstrap Alumina compiler (alumina-boot) is written in Rust and is actively developed. It compiles to ugly C11 code with GCC extensions (works on Clang too).

Finished:

To be done:

Full list of missing features, open questions, bugs and ideas for the future is in MISSING.md

Try it out

Don't want to install anything? Try https://play.alumina-lang.net, an online compiler playground.

You can do it with Podman/Docker:

# With Podman
alias alumina-boot='podman run -v $(pwd):/workspace ghcr.io/alumina-lang/alumina-boot:latest'
# With Docker
alias alumina-boot='docker run -u $(id -u ${USER}):$(id -g ${USER}) -v $(pwd):/workspace ghcr.io/alumina-lang/alumina-boot:latest'

alumina-boot hello_world=./examples/hello_world.alu -o hello.c
cc hello.c -o hello
./hello

Otherwise, follow the instructions to build it from source.

Prerequisites

To compile alumina-boot compiler from source, these prerequisites are needed:

Additionally, to compile the tools, such as alumina-doc, these prerequisites are needed:

git clone https://github.com/tree-sitter/tree-sitter
cd tree-sitter
make
sudo make install
# sudo ldconfig
git clone https://github.com/ianlancetaylor/libbacktrace
cd libbacktrace
./configure
make
sudo make install

Building

To compile alumina-boot compiler from source, run:

make alumina-boot

Now you are able to compile Alumina code, e.g.

./alumina-boot --sysroot ./sysroot hello_world=./examples/hello_world.alu -o hello_world.c
cc hello_world.c -o hello_world
./hello_world

If you wish to run the tests, simply add --cfg test. In this case the main() function will be replaced by the test runner.

./alumina-boot --sysroot ./sysroot hello_world=./examples/hello_world.alu -o hello_world_test.c
cc hello_world_test.c -o hello_world_test
./hello_world_test

If you wish to compile with multithreading enabled, add --cfg threading and link with libpthread.

./alumina-boot --cfg threading --sysroot ./sysroot hello_world=./examples/threading.alu -o threading.c
cc threading.c -o threading -lpthread
./threading

To compile the self-hosted compiler, run:

make aluminac

See the language guide, assorted examples, standard library for a tour of the language.

Contributing

Issues, pull requests, and feature requests are most welcome. Standard library is covered with tests, and there are also documentation tests (all examples from the standard library are compiled and executed as test cases).

To run the standard library tests

make test-std

To run the documentation tests

make test-docs

Standard library contributions are especially welcome! Ideas for contribution:

Projects using Alumina

Needless to say, a great way to contribute to the project is to just use Alumina for your own programs and libraries. Submit a PR and add your project to the list: