Build your own programming language from zero.
desugar is a browser-hosted compiler studio that walks you through building a real programming language. You start with raw text, grow a working compiler pass by pass, and finish with a programming language you can eject as its own standalone project. The language track is ML/Gleam-inspired, but the programming language you build is yours.
Most compiler material either stays academic or drops you into a half-built codebase. desugar takes a different approach: you build a complete programming language, end to end.
- start from raw text and produce your first tokens
- grow a real programming language instead of working through disconnected exercises
- give your programming language a name, file extension, and CLI identity
- test, benchmark, and unlock the next milestone in the browser
- eject the finished programming language into its own repo
Today, the repo already includes:
- a browser UI for milestone and lesson progression
- learner onboarding that creates a named programming language workspace
- single-file editing with save, reset, run-all, and per-test reruns
- lesson-wide hints with score penalties
- fixed benchmark tiers with bonus points
- repo-local progress persistence in
.desugar/desugar.db - export of the finished programming language into
exports/<slug>/
The current repo is organized around three layers:
crates/desugar/: the web app, progression engine, workspace API, scoring, and eject flowtemplates/ml-canonical/: the canonical seed programming language that gets personalised intolanguages/<slug>/desugar-challenges/anddesugar-solutions/: lesson fixtures and references that power the current challenge flow
When a learner creates a profile, desugar generates a working programming language workspace like this:
languages/aster/
|-- Cargo.toml
`-- compiler/
|-- Cargo.toml
|-- src/
| `-- lib.rs
|-- stub.rs
`-- tests/
|-- benchmark_compile.rs
|-- evaluate_expressions.rs
|-- parse_expressions.rs
`-- text_and_tokens.rs
That generated workspace is the programming language you grow over time. The long-term direction is a full compiler journey from foundational text processing through parsing, typing, modules, lowering, backends, and eventually ejecting a usable programming language repo.
- Rust toolchain with
cargo - Node.js if you want to run the browser-side test file
The browser UI source now lives in the sibling shared workspace at:
/home/markw/projects/studying/studying-ui
For frontend-only iteration:
pnpm --dir /home/markw/projects/studying/studying-ui run dev:desugarTo sync the latest built bundle back into this Rust app:
pnpm --dir /home/markw/projects/studying/studying-ui run build:allcargo run -p desugarThen open:
http://127.0.0.1:4001
This is the smallest useful loop in the current build.
cargo run -p desugarUse a profile like:
- language name:
Aster - slug:
aster - file extension:
.ast - CLI name:
aster - package namespace:
aster
That will generate languages/aster/ inside the repo.
Open the first lesson and work in:
languages/aster/compiler/src/lib.rs
The starter file is intentionally tiny. A first concrete implementation can be as small as:
pub fn compile(source: &str) -> String {
source.split_whitespace().collect::<Vec<_>>().join(" ")
}You can run the generated language tests directly from the terminal:
cargo test --manifest-path languages/aster/Cargo.toml -p aster-compilerOnce the core lesson is completed, the studio can export your language into:
exports/aster/
That gives you a standalone programming language repo you can take further on its own.
These are the current project checks:
cargo fmt
cargo test -p desugar
node --test crates/desugar/static/app.test.mjs
pnpm --dir /home/markw/projects/studying/studying-ui testdesugar is being shaped into a programming language incubator:
- foundations first: text, tokens, parsing, and simple evaluation
- one canonical ML/Gleam-like programming language track
- light personalisation without forking the curriculum
- backends that can graduate over time, starting from the simplest useful path
- eject the programming language into a separate repo once it is strong enough
The current implementation already supports the studio workflow, generated programming language workspaces, scoring, persistence, and export. The broader compiler journey is the next layer to build on top of that foundation.
