Skip to content

Repository files navigation

Margarine banner

margarine

A programming language with simple syntax, simple semantics,
and LLVM-based native and WebAssembly compilation.

Version License Stars Release

Overview

margarine is a statically typed, Rust-inspired programming language with traits, generics, enums, pattern matching, closures, iterators, and explicit mutability—without a borrow-checker-driven programming model.

Its LLVM-based compiler continues through diagnostics and can produce a usable binary even when source errors remain. If execution reaches an error path, Margarine traps there with the corresponding diagnostic.

Install

On supported systems:

curl -fsSL https://cdn.daymare.net/margarine/install.sh | sh

The installer downloads the published compiler and host toolchain as one managed, versioned installation. Use margarine update for later releases.

Note

Windows is not currently supported. The compiler presently relies on Unix-specific functionality in parts of the compiler and toolchain.

Supported targets

Target Output
arm64-apple-darwin Native executable or .dylib shared library with --shared
x86_64-unknown-linux-gnu Native executable or .so shared library with --shared
aarch64-unknown-linux-gnu Native executable or .so shared library with --shared
wasm32-unknown-unknown WebAssembly module (.wasm), including shared modules with --shared

Project status

margarine is still early-stage. Patch releases aim to remain backwards-compatible within a minor version, while minor releases may introduce breaking changes to the language, standard library, or tooling.
This may change after version 1.0.0.

Usage

A simple Margarine program may look like this:

fn main() {
    println("Hello!");
}

For more examples, see the examples folder.

CLI quick reference

margarine run examples/hello.mar
margarine build examples/hello.mar
margarine build --shared examples/hello.mar
margarine check examples/hello.mar
margarine test tests/core.mar
margarine update
margarine toolchain add wasm32-unknown-unknown

Building from source

Building from source requires Rust nightly, LLVM 18, and clang. Building for WebAssembly also requires the LLVM 18 Wasm linker.

On macOS:

brew install llvm@18
export LLVM_SYS_181_PREFIX="$(brew --prefix llvm@18)"
export PATH="$LLVM_SYS_181_PREFIX/bin:$PATH"

On Debian or Ubuntu:

sudo apt-get install llvm-18 llvm-18-dev libpolly-18-dev clang-18 lld-18
export LLVM_SYS_181_PREFIX=/usr/lib/llvm-18
export PATH="$LLVM_SYS_181_PREFIX/bin:$PATH"

Then build and run the compiler from the repository root:

git clone https://github.com/todaymare/margarine
cd margarine
cargo +nightly build -p margarine
cargo +nightly run -p margarine -- run examples/hello.mar

Contributing

See CONTRIBUTING.md for development and commit-message conventions.

License

This project is available under the MIT License.

Image credit

Banner image: Shuttle Over Earth, NASA / Expedition 22 Crew, via NASA's Astronomy Picture of the Day.

About

A statically typed language with simple syntax, simple semantics, and LLVM-based native and WebAssembly compilation.

Topics

Resources

Contributing

Stars

57 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages