Skip to content

mlang-org/mlang

Repository files navigation

The MLang logo

CI License: MIT C++23 Spec


What is MLang?

MLang is a general-purpose programming language that aims for the productivity of Kotlin/Swift and the performance of Go/C#, while guaranteeing memory safety without a stop-the-world garbage collector. It compiles ahead-of-time to native code through an LLVM backend.

namespace com.example.hello

import std.io.Console

public fn main() {
    let name: "world"
    Console.println("Hello, ${name}!")
}

Design pillars

  • Memory safety without a tracing GC. A hybrid of compile-time ownership (move semantics + borrow checking) and automatic reference counting with compiler-elided counts. No leaks, no dangling pointers, no use-after-free, no double free — and predictable, pause-free latency. (An optional backup tracing collector can be switched on for cyclic graphs.)
  • Null safety by construction. T is never null; T? is. Safe-navigation (?.), Elvis (?:), and the null-coalescing operators make absence explicit.
  • Structured concurrency. First-class coroutines (async/await, launch), CSP-style Channel<T>, and a work-stealing scheduler.
  • One obvious way to build. mbuild for builds, mango for packages, mfmt for formatting, mls for editor intelligence — all first-party.
  • Fast, parallel, incremental compilation. The compiler is multi-threaded end to end with a persistent on-disk cache.

Toolchain

Tool Binary Purpose
Compiler mlangc Lexing → … → native code generation.
Runtime mlang-runtime Allocator, scheduler, intrinsics.
Package manager mango Dependencies, publishing, registry.
Build tool mbuild Project orchestration.
Formatter mfmt Canonical code style.
Language server mls LSP for any editor.

File extension: .m

Install

Prebuilt installers are published on the releases page. Installing MLang always installs the mango package manager with it (mango is a required dependency). mango can also be installed on its own from the mango releases.

Linux (Debian / Ubuntu)

base=https://github.com/mlang-org/mlang/releases/latest/download
curl -LO $base/mlang_0.1.0_amd64.deb
sudo apt install ./mlang_0.1.0_amd64.deb

The mlang package depends on mango, so both must be installed together.

Linux (Fedora / RHEL)

base=https://github.com/mlang-org/mlang/releases/latest/download
sudo dnf install $base/mlang-0.1.0-1.x86_64.rpm $base/mango-0.1.0-1.x86_64.rpm

Windows

Download mlang-0.1.0-win64.msi from the releases page and run it. mango is included and installed automatically with the toolchain.

After installing, verify:

mlangc --version
mango --version

Quick start

# Build the toolchain (frontend + tools build without LLVM; add
# -DMLANG_ENABLE_LLVM=ON for native codegen)
cmake --preset dev
cmake --build --preset dev

# Tokenize / parse a program with the compiler driver
./build/dev/compiler/mlangc --emit=tokens examples/hello.m
./build/dev/compiler/mlangc --emit=ast    examples/hello.m

# Create and run a project (once mbuild/mango are wired to the backend)
mbuild new hello && cd hello
mbuild run

Documentation

The full language and compiler design lives in docs/design/ — 39 chapters covering everything from the type system and IR to the memory model, concurrency, ABI, and the roadmap. The formal grammar is in docs/grammar/mlang.ebnf.

Project status

MLang is in early development. The design is complete and the compiler frontend (lexer, parser, AST, diagnostics) is functional; semantic analysis, the IR, and the LLVM backend are under active construction. See the roadmap and development phases.

License

MLang is distributed under the MIT License.