Reef

A systems language unlike anything else.

Reef pairs Oberon’s Active Objects with the expressiveness of Ruby and Crystal — compiled to native code, from userland to bare metal.

Apache-2.0Active development
counter.reef
active object Counter
    value: int

    init()
        self.value = 0
    end init

    exclusive proc incr()
        self.value = self.value + 1
    end incr

    shared fn get(): int
        return self.value
    end get
end Counter

Reef is a statically-typed systems language that combines three things which rarely appear together: the Active Object concurrency model from Oberon, the expressiveness of languages like Ruby and Crystal, and native compilation that runs anywhere from userland to bare metal.

Each Active Object owns its state and guards it with a lock, so concurrent access is synchronized by the language rather than by programmer discipline — exclusive methods take the write lock and are mutually exclusive; shared methods take a reader lock and run concurrently, and the compiler rejects any attempt to mutate the object’s state from a shared method. The result is data-race freedom for Active Object state, enforced at compile time.

The syntax is built for people, not for parsers: end-based blocks, string interpolation, pattern matching with guards, generics, sum types, and traits. Reef compiles to C and then to native code through GCC or Clang — the same toolchain path, and the same optimizer, that C code takes.

Core strengths

What sets Reef apart.

Active Objects

Language-level safe concurrency. exclusive methods take the write lock, shared a reader lock; mutation from a shared method is rejected at compile time. Objects declaring run() get their own thread.

Modern type system

Generics with monomorphization, sum types, pattern matching with exhaustiveness checking, traits, and closures with escape analysis.

Clean syntax

End-based blocks, Ruby/Crystal-like elegance, string interpolation, pattern matching with guards, and default parameters.

Systems reach

Native compilation via a C backend. Inline assembly for AMD64, ARM64, and RISC-V. Freestanding builds for OS development.

Examples

Real programs you can read and run.

Every entry below compiles and runs verbatim — source and real output, side by side. Click any example to see the code.

Technical details

Under the hood.

Compilation

Lexer, parser, type checker, and code generator produce readable C. GCC or Clang compiles that to native executables — no VM, no runtime dependency.

Runtime

~10,400 lines of C99. Mark-and-sweep garbage collector with concurrent marking and lazy sweeping. Precise stack scanning via a shadow-frame chain: the collector knows exactly which slots hold pointers.

Standard library

20 packages, 138 modules: collections, I/O and filesystem, text processing, encoding (JSON, YAML, TOML, CSV, MessagePack, base64), hashing, compression, and networking (TCP, UDP, Unix sockets, DNS, HTTP, TLS).

OS development

A reef-os library for kernel programming: CPU primitives, serial drivers, spinlocks, and Limine bootloader support.

License & availability

Open source, and yours to build on.

Reef is open source under the Apache License 2.0 with the LLVM runtime-library exception. Programs you compile carry no attribution obligation from the embedded runtime, and Reef code may be combined with GPLv2 software. Apache-2.0 includes an explicit patent grant, and no contributor license agreement is required.

Reef is developed by Leafscale, LLC. Because it is Apache-2.0 licensed, anyone can fork, build on, and continue it independently of us.

  • Platforms — Linux, macOS, FreeBSD, OpenBSD, NetBSD, Zygaena (hammerhead)
  • License — Apache-2.0 WITH LLVM-exception
  • No CLA required to contribute

Write something in Reef.

Install the compiler, read the guide, and build your first Active Object at reeflang.dev.

Visit reeflang.dev → Read the docs

Output