x2c

x2c is a language for people who love to code.

Every programming language is built around a few values that determine what is easy or awkward to express. Python values readability and comes with batteries included. C values a small and fast mapping to the machine. Lisp values code and data being the same. Languages are opinionated because their goals conflict, and each one picks its priorities.

x2c is a quirky little language that would rather not pick. Static or dynamic, mutable or immutable, compile-time or run-time, managed or unmanaged: every option stays available. x2c is picky about one thing only, which is that it all stays one small language. The same code works in every mode, from single bits up to whole systems. You can change your mind or your paradigm without changing languages.

All of which makes x2c sound like a language with no values. It has three: love, power, and magic, and we know how that sounds. Nonetheless, see the panel for the values translated into code.

Under the hood, x2c is a superset of C that compiles to C, so everything stays close to native representations and works with the entire C ecosystem. If you know C, you already write x2c.

Why bother? Because programming is not about making computers do things; it is about helping brains think things, and x2c is a language for thinking in code.

Some users report heightened expressiveness, a sense of universality, and a touch of transcendence. Be sure to drink plenty of water.

Install x2c

x2c is experimental. Expect changes between releases.

Platforms. macOS 15 or later (arm64, x86_64); Linux with glibc 2.38 or later on x86_64 or arm64 (aarch64); Windows through WSL2.

from install to a running program
curl -fsSL https://x2c-lang.dev/install.sh | sh
export PATH="$HOME/.local/x2c/bin:$PATH"
x2c run ~/.local/x2c/examples/foreach.x

Install native binaries. One command downloads the compiler, runtime, headers, and examples for your platform into ~/.local/x2c. The installer needs a C compiler named cc. See the package installation instructions to add packages. The release notes list what changed and how to upgrade.

Or build from source. Follow the source installation instructions to build a checkout and install x2c into your home directory.

Put packages to work

Draw a chart, build a desktop or terminal app, query data, or train a model. Below is one working example from each of ten packages, with code, its result, and the complete source and setup instructions.

Packages give libraries their own namespaces, so you can use them together without name collisions. Build once, then import by name. Shims and adapters add idiomatic x2c types and methods while keeping the native API available; Lisp bindings and decorators can extend the language itself.

Browse packages or learn how to import one.

Build and run the chart example
# From your x2c checkout
make build-safe
./configure --packages raylib

make -C packages/raylib short-example
cd packages/raylib
./builds/climate-trends
# Result: builds/climate-trends.png

Packages need their native libraries prepared first. Release bundles cover macOS and Linux on arm64 and x86_64; torch bundles cover macOS arm64 and Linux x86_64 only. raylib, SQLite, and x2cui have no release bundle and build from a source checkout.

about, docs, and source

Go further.

About x2c tells its story. Read the docs to learn the language and look up its library. Browse the source to see how it works or make it your own.

Repository counts from make stats.

core compiler43,818 / 9,552

code / comment lines in the core compiler.

library25,953 / 11,309

code / comment lines in the library source.

compiler commands18,345 / 1,749

10 command programs, including build/run, lint, graph analysis, and language server.

language components2,367 / 626

14 components implementing language features with macros and rewrite rules. Code / comment lines.

tests1,226

unit tests.

fixtures1,508

compiler fixtures.

examples85

showcase examples.

packages10

integrations with working examples.