Skip to main content

The Ξ (Xi) Programming Language

A statically-typed, ahead-of-time compiled language that makes dependency injection, function intent, and refined types first-class — compiled to native binaries through C, and self-hosting.

Get started → GitHub

Xi is self-hosting — its compiler is written in Xi and compiles its own source to a byte-identical fixpoint. The only non-Xi code is a small C runtime (the equivalent of a language's libc/libcore). You don't need any of that to write Xi — install the toolchain and go.

Install

On macOS (Apple Silicon + Intel) and Linux, install with Homebrew:

brew install code-by-sia/x/xi

Or grab a prebuilt tarball from the releases page and put its bin/ on your PATH. Either way you get xc (compiler) and xi (run tool + REPL); you just need a C compiler (cc) on PATH. Full steps: Getting started.

Highlights

  • Refined typestype Age = Number where value >= 0 and value <= 130, checked at construction.
  • Eight function kindsmapper, projector, predicate, consumer, producer, reducer, creator, action: intent is syntactic.
  • Dependency injection in the language — deps { ... }, module { bind ... }, App.resolve(Interface), conditional when bindings, singleton/transient.
  • where-guarded overloading — multiple functions with one name, selected by a guard.
  • Decision tables, interrupts, atoms, machines & events — business rules, resumable conditions, active-state stores, finite state machines, and publish/subscribe with the listener kind, all as language features.
  • Error handlingT! result types, ok/err, and ? propagation.
  • Serialization — a built-in std/json library.
  • Native output — compiles to a standalone binary via C; no VM, no GC.

A taste

import "std/log.xi"

type Age = Number where value >= 0 and value <= 130
type User = { name: String, age: Age }

predicate isAdult(u: User) { return u.age >= 18 }

mapper describe(u: User) -> String {
return u.name + " (" + u.age + ")"
}

async entry (logger: Logger) main(args: String[]) {
let u = User { name: "Ada", age: 36 }
if isAdult(u) { logger.info(describe(u)) }
}

module App {}
$ xc greeting.xi && ./build/greeting

Showcase

See Xi in a real application: eXstream is a music-streaming service whose backend is a set of Xi microservices (auth, file storage, playlist) behind an API gateway, with a React front end and Docker deployment — an end-to-end example of modules, dependency injection, the web framework, and JWT auth.

Ready? Head to Getting started.