pelagos · the open sea

Pelago

A self-hosting systems language.

Native code. No GC. No runtime.

hello.pel
fn main() {
    print("Hello, world")
}
output
Hello, world

What it is

Pelago compiles to native code with its own backend. There is no garbage collector and no runtime to ship. Memory is safe through value semantics, not a borrow checker, and the syntax is braces and newlines with a TypeScript-like feel.

  • Value semantics

    Values are read-only by default. inout and sink are written at the call site as well, so a call shows what it changes or consumes.

    See it
  • No exceptions, no null

    Errors are result values, absence is option, and ? passes either one up.

    See it
  • One switch

    Enums, lists and guards go through one pattern match, and exhaustiveness is checked.

    See it
  • Overflow traps

    Integer overflow stops the program instead of wrapping. The native backend keeps that exact behaviour and still measures against C.

    Benchmarks
  • Its own backend

    x86-64 for Linux and Windows and AArch64, with no linker and no libc. The compiler is a single tool with a formatter and a language server inside.

    Read the design
  • Self-hosting is the goal

    The stage 0 compiler is written in Rust with no dependencies. The plan is to rewrite it in Pelago itself.

    Source

A small program

This is real code from the repository. It type checks, runs in the interpreter and builds to a native executable. The website checks every example the same way before it is published.

#name and #(expr) put values into strings, //~ starts a doc comment, and for i of 1..=n loops over an inclusive range.

More examples

values.pel
//~ Sum the squares of 1 to n.
fn sum_squares(n: int) -> int {
    var total = 0
    for i of 1..=n {
        total += i * i
    }
    return total
}

fn main() {
    const n = 10
    print("sum of squares up to #n: #(sum_squares(n))")
}
output
sum of squares up to 10: 385

Where it stands

Early, and honest about it. The stage 0 compiler handles the whole language: it checks types and value semantics, runs programs in an IR interpreter and builds native executables. A formatter and a language server exist. It is not yet rewritten in Pelago, real threads and async suspension are still open, and there are no prebuilt downloads yet, so you build from source.

Pelago is open source under MIT OR Apache-2.0.