o2l

O²L is an object-oriented programming language with an interpreter in C++23 — everything is an object, no null, immutable objects, practical control flow.

C++experimentallanguage · interpreter · oop · immutabilitylanguages & frameworkssource on github

Why

Three ideas pushed to the end: every value is an object and is treated the same way; there is no null — absence is an Optional<T>; and objects are immutable, which removes a whole class of shared-mutable-state bugs. It borrows from Smalltalk, Java, Rust, Haskell and Kotlin, and keeps practical constructs where purity would hurt everyday code.

How

  • A tree-walking interpreter: lexer → parser → AST, where each of roughly 40 node types evaluates itself against a context. A bytecode compiler is on the roadmap.
  • The whole value space is a single std::variant — numbers, text, objects, enums, records, protocols, collections and their iterators, results, coroutine handles, channels and FFI types. Long is a real 128-bit integer where the platform has one, with a fallback on MSVC.
  • Object, Protocol (interfaces), Record, Enum and generics like Map<Text, List<Int>>. Properties are immutable after construction; locals inside methods can be reassigned — a deliberate concession. Methods are private unless marked @external.
  • Errors are throw/try/catch/finally plus Result<T, E>.
  • Green threads with spawn { … }, a coroutine scheduler and channels; an I/O thread pool for async work.
  • A libffi-based FFI for calling C libraries, with SQLite bindings as the showcase.
  • A standard library for text, math, JSON, URLs, regex, HTTP client and server, dates, filesystem and OS — plus o2l-pkg, o2l-fmt, a language server with a Neovim plugin, 478 tests and CI on Linux, macOS and Windows.

Documentation lives at docs.o2l.dev.

Object Greeter {
    property message: Text
    constructor(greeting: Text) { this.message = greeting }
    @external method greet(name: Text): Text {
        io.print("%s, %s!", this.message, name)
        return this.message
    }
}
$ git clone https://github.com/zombocoder/o2l
← all projects