Skip to content

A self-hosted low-level functional-style programming language ๐ŸŒ€

Notifications You must be signed in to change notification settings

anoojpatel/metaxu

Repository files navigation

Metaxu๐ŸŒ€

A self-hosted Low level functional-style programming language
[Documentation]

What is Metaxu?

Metaxu is a modern systems functional programming language that prioritizes speed, safety, and developer joy. Currently written in Python, it compiles through a TapeVM intermediate representation into optimized C code. Our ultimate goal? To bootstrap Metaxu in itself, creating a language that's so elegant and intuitive that writing its own compiler becomes a delightful challenge.

Core Features

  • ๐Ÿš€ Zero-cost abstractions with unboxed references and move semantics
  • ๐Ÿ›ก๏ธ Memory safety through simple modal borrow checking
  • โšก Powerful algebraic effects system
  • ๐Ÿงฌ Advanced type system with algebraic subtyping and row polymorphism
  • ๐Ÿ”„ Pattern matching and compile-time metaprogramming
  • ๐Ÿงต First-class concurrency with SIMD and multithreading
  • ๐Ÿ“ฆ Cross-platform portability

Philosophy

The name "Metaxu" comes from philosopher Simone Weil's concept of divine intermediaries. Just as a wall between prison cells becomes both a barrier and a medium for communication through taps, Metaxu serves as a bridge between high-level abstractions and low-level performance. It connects human intention to machine execution, striving to make systems programming both powerful and accessible.

Deeply inspired by Ante, Hylo, Sage, Oxidized OCaml, Rust, Zig, and Python, we're building a language that embraces both pragmatism and purity. Our goal is to create a tool that helps programmers express their ideas clearly and efficiently, while ensuring their code remains fast and reliable. Furthermore, we want to create a language that's accessible to everyone, regardless of their background or experience level, so that anyone can learn how to build compilers.

Installation

Prerequisites

  • Python 3.11 or higher
  • GCC compiler
  • uv (Fast Python package installer)

Setup

  1. Install uv:
# On macOS
brew install uv

# On Linux/WSL
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Clone the repository:
git clone https://github.com/yourusername/metaxu.git
cd metaxu
  1. Install dependencies:
# Install all dependencies including dev tools
uv sync --all

# Or install only runtime dependencies
uv sync
  1. Use Metaxu Compiler:
$ metaxu --help

 usage: metaxu [-h] [--target {vm,c}] [--output OUTPUT] [--optimize] [--debug] [--dump-ir] [--dump-ast] [--run] [--link-mode {static,dynamic,library}]
              [--library-name LIBRARY_NAME] [--cuda]
              files [files ...]

Metaxu compiler

positional arguments:
  files                 Source files to compile

options:
  -h, --help            show this help message and exit
  --target {vm,c}       Compilation target (default: vm)
  --output, -o OUTPUT   Output file
  --optimize, -O        Enable optimizations
  --debug, -g           Include debug information
  --dump-ir             Dump VM IR
  --dump-ast            Dump AST
  --run                 Run in VM after compilation
  --link-mode {static,dynamic,library}
                        Linking mode (default: static)
  --library-name LIBRARY_NAME
                        Library name (for library builds)
  --cuda                Enable CUDA support

Helping LLMs

We have a llm-ctx.txt file that contains some examples of how to use Metaxu with LLMs. It follows llms.txt standards. Add it via @docs for IDEs or into relvant context manager protocols.

Development

Running Tests

The project uses doit as its task runner. Here are the common commands:

# List all available tasks
doit list

# Run all tests (C and Python)
doit test

# Run specific test suites
doit test_python           # Run Python tests only
doit test_atomic_effects   # Run atomic effects test
doit test_effect_runtime   # Run effect runtime test

# Clean build artifacts
doit clean

Test binaries are output to the outputs/ directory.