Claude just wrote a working compiler for a language I invented in 20 minutes
I described a new programming language spec in plain English and asked Claude to build a compiler. It generated a lexer, parser, AST, and code generator in TypeScript. Everything works. I'm shook.
Content
# MiniLang Compiler
My spec was basically:
- Statically typed, minimal syntax
- Pattern matching, algebraic types
- Compiles to JavaScript
Claude generated:
```typescript
// Lexer: 200 lines
// Parser: 350 lines
// AST types: 80 lines
// CodeGen: 250 lines
// Total: ~880 lines of working TypeScript
```
Example MiniLang code:
```
type Shape = Circle(radius: f64) | Rect(w: f64, h: f64)
fn area(s: Shape) -> f64 {
match s {
Circle(r) => 3.14159 * r * r,
Rect(w, h) => w * h,
}
}
let c = Circle(5.0)
print(area(c)) // 78.53975
```
It actually compiles and runs. I'm seriously questioning my career choices.#Compilers#Claude
44.1k
0