Programming is Dead.Long Live Programming.
x2c is a language for people who love to code.
x2c is a quirky little language that makes programming fun and a bit weird. It has legitimate applications, presumably, but is more about coding for the joy of it. Some users of x2c report heightened expressiveness, a sense of universality, with a touch of transcendence. Be sure to drink plenty of water.
x2c is C with batteries and without the bullshit.
It is a strict superset of C that compiles to C, keeping C’s
native performance, tooling, ecosystem, and portability while adding the
conveniences of a modern language. x2c extends C’s syntax with a few new
keywords, but the real magic is in the % and $ sigils, which let you write
code that combines static types, dynamic values, and compile-time computation.
x2c’s main features are summarized in the table on the right. Everything is optional and works with plain C as well. Hence, you can take existing C code and adopt x2c capabilities incrementally.
The compiler, library, and runtime are all written in x2c, with no third-party dependencies. You can read the source to learn the language, then change the language by editing the source. The repository counts give a sense of its size.
At this point, you may be wondering: why learn a new programming language, let alone create and release one, in a post-AI world? Fair question. Programming is not about making computers do things; it’s about helping brains think things. Now, more than ever, the best reason to code is to rewire your brain. So if programming is more than a career to you—if you code for love, power, or magic—try a bit of x2c.
Code is Love
Part of the pleasure of programming is finding a clear way to express an idea. We love C because it puts us close to the machine, with little between us and what it can do. But that closeness comes at a cost: even simple ideas can take a lot of housekeeping to express.
x2c keeps that directness and lets you focus on what your program does. Describe a whole configuration as readable, nested data. Work with text and collections through operations you can combine. Read a file without managing line buffers. Give your own types methods that feel as natural as the built-ins. C’s functions, libraries, and control remain within reach.
Nobody ever fell in love with boilerplate. x2c leaves more room for what you do love: turning an idea into code.
Explore the essentials: values, symbols, collections and literals, files, and methods.
Code is Power
Code becomes powerful when a few simple pieces open up many possibilities. Each capability becomes more useful through the others: collections give your types something to build on, iterators connect operations into flows, and imports bring C libraries into the same style of code.
With x2c, those combinations turn into working tools. Turn a stream of text into a ranked result. Build and query a search index. Send work to another thread and bring the answer back. Run a daily survey that reclaims working storage after each file and each day, without individual free calls. Substantial computations become compact enough that you can still see the idea running through them.
The pieces are small. What you build with them needn’t be.
Put the pieces together: collections, iteration, scopes, match, threads, exceptions, and packages.
Code is Magic
When you can change the language, repetition starts to look like an opportunity. A pattern you keep writing can become a construct you use. An idea that once needed a page of explanation can have a name, a syntax, and rules the compiler understands.
Give sets their own operators. Turn a locking convention into a statement that always releases the lock. Describe a family of values once and let Lisp generate the code that follows from it. Inside the finished program, use that same Lisp to make rules into data you can pass around and evaluate.
The compiler is written in x2c, too. Follow an idea far enough and you can change the tool you are thinking with, in the language you already use.
Explore the language itself: protocols, macros and compile-time Lisp, runtime Lisp, self-hosting, compiler inspection, and architecture.
Install x2c
Install a release. One command downloads the compiler, runtime, headers, and examples for your platform into $X2C_PREFIX (fresh scratch directory).x2c install <package> --index https://staging.x2c-lang.dev/packages/index.txt then adds packages from the package index.
Or build from source. Clone the repository, build the compiler from its checked-in C, and run one of the included examples. The compiler handles translation, native compilation, and execution.
You need a GCC- or Clang-compatible C compiler, ar, GNU Make, Python 3, and Bash. See the build instructions for the self-hosting process.
Just experimenting? make ape-build in a checkout produces a Cosmopolitan executable that bootstraps a minimal compiler and runtime for fun, without examples, the book, or packages. Releases do not publish it.
git clone https://github.com/gwf/x2c.git
cd x2c
git checkout --detach 44fa25e30ed593683c7e4269d41af2b0bec47842
make build-safe
export X2C_PREFIX="$(mktemp -d)/x2c"
curl -fsSL https://staging.x2c-lang.dev/install.sh | sh
export PATH="$X2C_PREFIX/bin:$PATH"
x2c run "$X2C_PREFIX/examples/foreach.x"
x2c install pcre2 --index https://staging.x2c-lang.dev/packages/index.txtPut libraries to work
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.
Draw a chart, build a terminal app, query data, or train a model. Explore one working example from each package below, with code, its result, and the complete source and setup instructions.
Browse packages or learn how to import one.
# 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 separate dependency preparation. Release bundles are built on macOS and Linux, on both arm64 and x86_64.
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.
code / comment lines in the compiler source.
code / comment lines in the library source.
code / comment lines in hand-written X Lisp source.
code / comment lines in hand-written X macro source.
unit tests.
compiler fixtures.
showcase examples.
Explore C libraries through working x2c examples.

