A programming language with simple syntax, simple semantics,
and LLVM-based native and WebAssembly compilation.
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.
On supported systems:
curl -fsSL https://cdn.daymare.net/margarine/install.sh | shThe 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.
| 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 |
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.
A simple Margarine program may look like this:
fn main() {
println("Hello!");
}For more examples, see the examples folder.
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-unknownBuilding 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.marSee CONTRIBUTING.md for development and commit-message conventions.
This project is available under the MIT License.
Banner image: Shuttle Over Earth, NASA / Expedition 22 Crew, via NASA's Astronomy Picture of the Day.
