U

U is a small language that compiles to C. Its thesis is simple: make whole classes of production bugs impossible to compile. The type system, conventions, and compile-time analysis are arranged so that mistakes which normally surface at 2am — a query that table-scans, a missing translation, an unimplemented adapter method — become build errors instead.

The reference compiler, u2c, is ~15,000 lines of Python that transpiles U to C99, which any C compiler then turns into a native binary.

Quick start

cd u2c
python3 -c "from u2c.cli import main; main(['init', '--example', 'hello'])"

That scaffolds a project with a working src/classes/App/Main.u. To build and run one of the bundled examples:

cd examples
./build.sh hello     # → Hello from U!
./build.sh fib        # → computes fib(10), exit code 55

See examples/README.md for all four (hello, fib, json, errors).

What "bugs become build errors" means, concretely

The headline feature is the index check. Given a class generated from your database schema, this:

Database.find[User](u => u.age > 30)

is a compile error if age is not covered by an index on users:

this query would table-scan 'users': the predicate filters on (age) but no index covers those fields (indexes: [id]). Add an index, or filter on an indexed field.

The compiler reads the predicate lambda, extracts the fields it touches, and checks them against the class's declared indexes using the same leftmost-prefix rule a real database uses. A performance cliff every ORM discovers in the slow query log is caught before the code ships.

The same philosophy runs through the platform:

Layout

Running the tests

cd u2c
python3 tests/test_parser.py
python3 tests/test_linter.py
python3 tests/test_codegen.py
python3 tests/test_optimize.py

1064 tests pass (119 parser + 345 linter + 594 codegen + 6 optimize). The codegen tests compile generated C with a real C compiler and run it, checking the output — so a passing codegen test means the whole pipeline (U → C → binary → correct result) works for that case.

Honest status

The standard library is 27 modules, all parsing. Non-generic programs run end-to-end. The design document (implementation.html) is candid about what is a working feature, what is a deliberate simplification, and what is a marked placeholder — for example, the cryptographic canonicalization (JCS, EIP-712), hashing (SHA-256, keccak256), AND signatures (ECDSA over P-256 and secp256k1) are all real, with the elliptic-curve arithmetic verified against the RFC 6979 test vector. Where a corner is cut, it is labeled as such rather than hidden.