Plank v0.1, a compiled language

A compiled language you can read in an evening.

One file turns structs, enums, closures, lists and dicts into a native binary. LLVM does the hard part. You get to read the rest.

fib.pk

Terminal

Real programs, real output, straight from the compiler.

A language, built in the open

The missing middle

Real compilers are a hundred thousand lines. Tutorials stop before a binary comes out. Plank is a real compiler you can finish reading.

60/60everyday things Python, Ruby and Swift do, all yes
1file is the whole compiler
2platforms, macOS and Linux
0.03sto run fib(35) natively

AI in the language

Python scripts computers. Plank scripts intelligence.

A model, a prompt, a tool and an agent are ordinary Plank. tool fn reads a function and the comment above it and tells the model how to call it.

No interpreter

Source to a native binary

Source becomes LLVM IR, LLVM optimizes it, your system linker finishes the job. The road a production compiler takes, in a much smaller car.

Types

Nothing behind your back

Structs, enums, optionals, closures and generics. match refuses to forget a case.

Strings and lists

The everyday things

Interpolation, slices, regex, map, filter, sort(by:) and packages from GitHub.

Tools

Around the language

A REPL, plank fmt, plank test and build --static.

How it works

Four steps, one file

Each step is a plain function or class, in the order you read them. The design rules come from Paul Graham's Hackers and Painters.

LexOne regex and a small scanner turn text into tokens.
ParseRecursive descent for statements, Pratt for expressions.
GenerateOne walk emits LLVM IR and checks types as it goes.
LinkLLVM optimizes, your C compiler links against libc.

What you can build

Programs it already runs

The test suite compiles and runs every one of them on every push. The output under each is theirs.

Run it

One line to install

Or clone the repo and run it from there. It needs a C compiler for linking; the first run fetches llvmlite on its own.

brew install nulljosh/tap/plank-lang
plank repl
plank run examples/fib.pk
plank build examples/fib.pk
plank test
plank fmt