Computer Science · intermediate
Compile a Tiny Language to WebAssembly
A compiler for a small expression language — lexer, parser, type checker, and a code generator that emits real WebAssembly binaries that run in the browser and in Node. You will understand what happens between source code and the machine.
Project overview
WebAssembly is production-ready in 2026 across browsers, serverless runtimes, and plugin systems, and a compiler that targets it proves you understand language design, runtimes, and binary formats in one artifact. It is the project that makes interviewers stop and ask questions.
Real-world use case
A product wants users to write safe custom formulas that run at native speed in the browser. Your language compiles to Wasm and runs in a sandbox with no eval and no server round trip.
Tools and technologies
- TypeScript or Rust
- Hand-written Lexer and Parser
- WebAssembly Binary Format
- WABT Tools
- Browser Runtime
Skills you can demonstrate
Compiler Construction, Parsing and ASTs, Type Checking, Code Generation, WebAssembly
Build roadmap
- Define the language
Write the grammar for expressions, variables, if/else, and while. Keep it small. Write ten example programs with expected outputs before writing any code. - Build the lexer and parser
Hand-write a tokenizer and a recursive-descent parser producing an AST. Test each grammar rule with a tiny program. - Add a type checker
Walk the AST and assign types. Reject programs that mix types or use undeclared variables, with line numbers in the error. - Emit WebAssembly text first
Generate WAT (the text format) from the AST and assemble it with WABT. Run it in Node. This proves your codegen logic before the binary work. - Emit the binary directly
Replace the WAT step with your own binary encoder — sections, LEB128 integers, opcodes. Validate with wasm-validate until it passes. - Build the playground
A single web page with an editor, a compile button, and output. Deploy it and link it from the README next to a diagram of the pipeline.
Ways to extend the project
Add functions and recursion, then a small standard library, then compile a recursive Fibonacci and benchmark it against JavaScript.
How to showcase your work
- GitHub: The compiler, a test suite of source programs with expected outputs, and a web playground where you type code and see the Wasm run.
- LinkedIn: Show the playground: type a loop, hit compile, watch it run in the browser at native speed. Keep it under 30 seconds.
- Resume: Be specific: "Built a compiler from a custom language to WebAssembly with a hand-written parser, static type checking, and direct binary emission."