{"id":51225540,"url":"https://github.com/code-by-sia/xi","last_synced_at":"2026-06-28T11:00:31.290Z","repository":{"id":362160658,"uuid":"1257653921","full_name":"code-by-sia/xi","owner":"code-by-sia","description":"The Ξ (Xi) Programming Language","archived":false,"fork":false,"pushed_at":"2026-06-27T13:39:20.000Z","size":1667,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-27T14:14:54.094Z","etag":null,"topics":["compiler","compiler-design","dependency-injection","language","microservices","programming","programming-language","x","xi"],"latest_commit_sha":null,"homepage":"https://code-by-sia.github.io/xi/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-by-sia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-02T22:12:00.000Z","updated_at":"2026-06-27T13:39:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/code-by-sia/xi","commit_stats":null,"previous_names":["code-by-sia/x","code-by-sia/xi"],"tags_count":77,"template":false,"template_full_name":null,"purl":"pkg:github/code-by-sia/xi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-by-sia%2Fxi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-by-sia%2Fxi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-by-sia%2Fxi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-by-sia%2Fxi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-by-sia","download_url":"https://codeload.github.com/code-by-sia/xi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-by-sia%2Fxi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34885802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","compiler-design","dependency-injection","language","microservices","programming","programming-language","x","xi"],"created_at":"2026-06-28T11:00:25.712Z","updated_at":"2026-06-28T11:00:31.217Z","avatar_url":"https://github.com/code-by-sia.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs/assets/logo-white.svg\"\u003e\n    \u003cimg alt=\"Xi programming language logo\" src=\"docs/assets/logo.svg\" width=\"140\" height=\"140\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eThe Ξ (Xi) Programming Language\u003c/h1\u003e\n\nXi is a **statically-typed, ahead-of-time compiled** language with **first-class\ndependency injection**, **eight function kinds**, and **refined types** that\nenforce their constraints. It compiles to native binaries through a C99 backend,\nand its compiler is **written in Xi and self-hosting**.\n\n```x\nimport \"std/log.xi\"\n\ninterface Greeter { mapper greet(name: String) -\u003e String }\n\nclass Friendly implements Greeter {\n    deps {}\n    mapper greet(name: String) -\u003e String {\n        return \"Hello, \" + name + \"!\"\n    }\n}\n\nmodule App {\n    id      = \"greeter\"          // name of the compiled binary\n    name    = \"Greeter\"\n    version = \"1.0.0\"\n    license = \"Apache 2.0\"\n\n    // the entry can live inside its module; dependencies are auto-wired.\n    // `entry` always returns Integer, so `-\u003e Integer` is optional and a body\n    // without a `return` exits 0.\n    async entry (logger: Logger, greeter: Greeter) main(args: String[]) {\n        logger.info(greeter.greet(\"Ada\"))\n    }\n}\n```\n\nA folder can hold several such modules; `xc --all` builds each into its own\nbinary (named by its `id`). The entry may also be written at the top level with a\nseparate `module App { … }` block — both forms work.\n\n## Why Xi\n\n- **Dependency injection \u0026 IoC are part of the language**, not a framework.\n  Implementations are discovered and wired automatically; `bind` is an optional\n  override.\n- **Eight function kinds** name a function's role and intent —\n  `mapper`, `projector`, `predicate`, `consumer`, `producer`, `reducer`,\n  `creator`, `action` — and the compiler enforces purity for the pure ones.\n- **Decision tables** (`decision` kind) express business rules as\n  `when \u003ccond\u003e =\u003e \u003cresult\u003e` arms (or a tabular `in`/`out` grid) — and, being a\n  function kind, they're DI-injectable and can call predicates.\n- **Interrupts** — resumable conditions: a function `signal`s and **suspends**;\n  an enclosing `try`/`catch` decides to `recover` (resume) or `skip` (abandon).\n  See [Interrupts](https://code-by-sia.github.io/xi/interrupts).\n- **Atoms** — active-state stores: an immutable `state` changed only via\n  `transition` reducers (Redux-style). See [Atoms](https://code-by-sia.github.io/xi/atoms).\n- **Machines** — finite state machines as immutable values: named `states`,\n  machine-wide `data`, transitions with parameters, `where` guards and `update`\n  clauses, `.can(...)`, and illegal moves that raise the resumable\n  `IllegalTransition` interrupt. See [Machines](https://code-by-sia.github.io/xi/machines).\n- **Events** — built-in typed publish/subscribe. Producers `publish(topic, dto)`\n  any DTO; the `listener` kind subscribes to a topic and receives the **typed**\n  value (no JSON). The default transport queues in memory with zero serialization;\n  bind your own `PublisherService`/`ConsumerService` to go external — producers and\n  listeners are unchanged. Deliver synchronously (`Events.run`) or on a worker\n  thread (`Events.runAsync`). See [Events](https://code-by-sia.github.io/xi/events).\n- **Web framework** — implement `WebRequestHandler` and route by overloading\n  `action handle(req, res)` with `where` guards; `res.send(dto)` / `req.parse(T)`\n  auto-(de)serialize via a pluggable `WebTransport` (JSON by default). No manual\n  JSON. Plain HTTP by default; opt-in **HTTPS** (`web.serveTLS`, `XC_TLS=1`) and\n  **HTTP/2** (`web.serveHttp2`, `XC_HTTP2=1`). See [Web](https://code-by-sia.github.io/xi/web).\n- **Share-nothing threading** — `parallel { }` blocks run on OS threads and yield\n  a `Thread` handle (`stop`/`wait`/`running`); threads talk only over thread-safe\n  channels. See [Threading](https://code-by-sia.github.io/xi/threading).\n- **Refined types** carry constraints (`type Age = Number where value \u003e= 0`)\n  that are **checked at construction**.\n- **Sum / algebraic types** (`type Shape = | Circle { r: Number } | Empty`) with\n  payload-binding `match` — lowered to tagged unions.\n- **Result-based error handling** (`T!`, `ok`/`err`, `?` propagation) — no\n  exceptions.\n- **`where`-guarded overloading**, `match`, optionals (`T?`), arrays (`T[]`),\n  and a `Bytes` type for binary data.\n- **C interop** — port a C library by declaring it in an `extern \"C\"` block with\n  `link`/`pkg`/`cflags` build directives; `Ptr`/`cstring` types, `\u0026mut`\n  out-params, and a `std/ffi` String↔cstring bridge. See\n  [C interop](https://code-by-sia.github.io/xi/ffi) (e.g. a SQLite binding).\n- **Multi-file projects** with `import` and `namespace`, plus a module\n  `dependencies` field — list source-archive URLs and `xi install` fetches them\n  into `./modules` (auto-compiled in, no manual `import`).\n- **A growing standard library** — math, text, bytes, convert, **serialization\n  (json / yaml / xml)**, **crypto (SHA/HMAC/base64/CSPRNG)**, fs, path,\n  **net (TCP sockets)**, **http (HTTP/1.1 client)**, **web (REST framework)**,\n  **thread (share-nothing threads + channels)**, process, time, **ffi (C\n  interop)** — see\n  [the standard library](https://code-by-sia.github.io/xi/stdlib) and\n  [serialization](https://code-by-sia.github.io/xi/serialization).\n- **Native, dependency-light output**: Xi → C99 → a native binary via your `cc`.\n- **Runs on the web too**: the same source compiles to WebAssembly with\n  `xc --target wasm` (via Emscripten). See [the WASM guide](https://code-by-sia.github.io/xi/wasm).\n\nFull feature matrix: **[FEATURES.md](FEATURES.md)**. Full guide:\n**[code-by-sia.github.io/xi](https://code-by-sia.github.io/xi/)**.\n\n## Quick start\n\nOn macOS (Apple Silicon + Intel) and Linux, install with **Homebrew**:\n\n```sh\nbrew install code-by-sia/xi/xi\nbrew upgrade xi        # later, to update\n```\n\nOr download a prebuilt toolchain for your platform from the\n**[releases page](https://github.com/code-by-sia/xi/releases)**, unpack it, and\nput its `bin/` on your `PATH`:\n\n```sh\n# grab the asset for your platform, e.g. xi-\u003cversion\u003e-macos-arm64.tar.gz\ntar -xzf xi-\u003cversion\u003e-\u003cos\u003e-\u003carch\u003e.tar.gz\nexport PATH=\"$PWD/xi-\u003cversion\u003e-\u003cos\u003e-\u003carch\u003e/bin:$PATH\"\n```\n\nEither way you get `xc` and `xi`:\n\n```sh\nxc hello.xi        # compile  -\u003e build/hello\nxc --all           # build every module project under the current dir\nxi hello.xi        # compile and run\nxi                 # interactive REPL\nxi version         # print the toolchain version\nxi update          # self-update to the latest release (tarball installs)\nxi skill           # print the AI-agent language guide (xi skill \u003e SKILL.md)\nxt file_test.xi   # run tests (also: xt --all)\nloadtest --bench app.xi   # load/perf test (--compile / --bench / --http)\n```\n\nOnce installed, `xi update` upgrades the toolchain in place (downloads the latest\nrelease for your platform and replaces the binaries, runtime, and stdlib).\n\nThe bundle ships the `xc` compiler, the `xi` REPL / run tool, the runtime, and\nthe standard library; the `bin/` wrappers set `XC_RUNTIME` / `XC_STD` for you.\nYou need a C compiler (`cc` / `clang` / `gcc`) on `PATH`, since `xc` produces\nnative binaries via C. (To build from source instead, run\n`./compiler/bootstrap.sh` — see\n[github.com/code-by-sia/xi](https://github.com/code-by-sia/xi).)\n\nRuns on **Linux** (x86_64/arm64) and **macOS** (arm64/x86_64). On **Windows**,\nuse **WSL2** and follow the Linux steps, or run the toolchain in **Docker** (no\nnative Windows build yet):\n\n```powershell\ndocker build -t xi .\ndocker run --rm -v \"${PWD}:/work\" xi xi hello.xi   # compile + run\ndocker run --rm -v \"${PWD}:/work\" xi xc hello.xi   # compile -\u003e build/hello\ndocker run --rm -it -v \"${PWD}:/work\" xi xi        # REPL\n```\n\nThe image downloads a published release; pin one with\n`--build-arg XI_VERSION=v0.0.14`. See the [`Dockerfile`](Dockerfile).\n\n## Documentation\n\nFull documentation — the language guide, dependency injection \u0026 IoC, decision\ntables, interrupts, atoms, state machines, events, serialization, the standard\nlibrary, and the compiler internals — lives in the repository at\n**[github.com/code-by-sia/xi](https://github.com/code-by-sia/xi)**\n(rendered at [code-by-sia.github.io/xi](https://code-by-sia.github.io/xi/)).\n\n## Showcase\n\n**[eXstream](https://github.com/code-by-sia/eXstream)** is a full real-world app\nbuilt with Xi — a music-streaming service whose backend is a set of Xi\nmicroservices (auth, file storage, playlist) behind an API gateway, with a React\nfront end and Docker deployment. It's a good end-to-end example of structuring a\nlarger project with modules, dependency injection, the web framework, and JWT\nauth.\n\n## Project layout\n\n```\ncompiler/   the compiler, written in Xi (lexer, parser, codegen, driver) + xc_helpers.c\n            plus bootstrap.sh / fetch-seed.sh / selfhost.sh\nruntime/    the C runtime (runtime.h, runtime.c) — the Xi equivalent of libc/libcore\nstd/        standard library (math, text, bytes, convert, json, yaml, xml, crypto, events, web, io, fs, path, net, http, process, time)\nexamples/   runnable programs, incl. proj/ (multi-file) and showcase/ (full project)\ndocs/       documentation (Docusaurus site under website/)\neditors/    Tree-sitter grammar, Zed extension, Vim plugin\n```\n\n## Editor support\n\nA Tree-sitter grammar plus **Zed** and **Vim** integrations live in\n[`editors/`](editors/). The grammar parses every `.xi` file in this repo.\n\n## License\n\nXi is licensed under the **Apache License 2.0** — see [LICENSE](LICENSE) and\n[NOTICE](NOTICE). It is provided **\"AS IS\",\nwithout warranties of any kind, and with no obligation of support**\n(Apache-2.0 §7–§8). It's an experimental personal project — issues/PRs are\nwelcome, but no support or maintenance is guaranteed. See\n[CONTRIBUTING.md](CONTRIBUTING.md) and [SUPPORT.md](SUPPORT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-by-sia%2Fxi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-by-sia%2Fxi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-by-sia%2Fxi/lists"}