Back to browse
GitHub Repository

C – but better

3 starsPython

Btrc – I built a language with AI in a few weeknights that outputs C11

by schiffy·Mar 2, 2026·5 points·1 comment

AI Analysis

●●●BangerWizardryBig BrainZero to One

Modern language that generates clean C11—not a wrapper, actual compiler pipeline with formal grammar and LSP.

Strengths
  • End-to-end compiler pipeline (6 stages: lexer→parser→analyzer→IR→optimizer→emitter) grounded in formal EBNF and ASDL specs—genuine language design, not scaffolding.
  • Generated C is strict C11, readable, linkable with standard toolchains—zero runtime magic, inspectable output.
  • Monomorphized generics, ARC, exception handling, WebGPU support, and a working VS Code LSP with completions—ships as a usable tool, not a proof-of-concept.
Weaknesses
  • Early project (0 stars, fresh GitHub), no production code examples or ecosystem to speak of yet.
  • Built partly with AI assistance—unclear which components were hand-crafted vs. generated, raising durability and maintenance questions.
Target Audience

Systems programmers, embedded developers, C enthusiasts wanting modern syntax without leaving the C ecosystem

Similar To

Zig · Vale · Nim

Post Description

btrc is a statically-typed language that transpiles to C11. It adds classes, generics (monomorphized), type inference, lambdas, f-strings, collections (Vector, Map, Set), threads, GPU compute via WebGPU, ARC memory management, exception handling, and a standard library — while generating strict C11 with no runtime, no GC, and no VM.

The compiler is a 6-stage Python pipeline (lexer → parser → analyzer → IR gen → optimizer → C emitter) driven by a formal EBNF grammar and an algebraic AST spec (Zephyr ASDL). The generated C is readable and linkable with any C11 compiler. It ships with a VS Code extension (LSP with completions, diagnostics, go-to-def, hover) and 930 tests.

I've wanted to build something like this for about 10 years, but it was always too ambitious to do on the side. With AI, I was able to build it over a handful of evenings after work. Some things worth noting:

A few things that I find fun / interesting / noteworthy:

- The EBNF grammar and ASDL spec are the single source of truth — the lexer, parser, and AST node classes are all derived from them, not hardcoded

- Generics are monomorphized (like C++ templates / Rust), so zero runtime overhead but binary size grows per type combination

- ARC handles most memory management including cycle detection and cleanup on exceptions — no GC, deterministic destruction

- The entire stdlib (collections, math, datetime, IO, threading) is written in btrc itself

- @gpu functions transpile to WGSL compute shaders with auto-generated WebGPU boilerplate — array params become storage buffers, scalars become uniforms

- The generated C is meant to be readable — you can step through it in gdb/lldb and it mostly makes sense (just verbose with lots of underscores)

- There's a 3D game engine example (ball + WASD + jump + shadows + raymarching) that's ~570 lines of btrc across 11 small modules

- The VS Code extension reuses the compiler's own lexer, parser, and analyzer — diagnostics match exactly what the compiler reports

- btrc inherits C's memory model wholesale — no borrow checker, no lifetime analysis. You can absolutely still shoot yourself in the foot

- The whole thing was built in a few evenings after work with heavy AI assistance, which felt like the most interesting part of the project honestly

Similar Projects

Developer Tools●●Solid

Lumina – a statically typed web-native language for JavaScript and WASM

Built-in reactive runtime and dual JS/WASM targets challenge React and TypeScript dominance.

WizardryBold Bet
light_ideas
202mo ago

A New Programming Language

Endianness in the type system is clever, but another language in a saturated field.

Niche Gem
kvthweatt
403mo ago