A minimal 300-line language implementation called Calcium demonstrates how languages like Python actually work under the hood, including a tokenizer, parser, AST, compiler, bytecode, and execution engine. The project was built to help explain the common confusion around whether Python is interpreted or compiled, showing that Python programs never become native CPU instructions but instead run as bytecode. It's offered as a simple starting point for anyone wanting to experiment with building their own language implementation.

1m read timeFrom nedbatchelder.com
Post cover image

Questions this post answers

Is Python interpreted or compiled?

Python is both: source code is compiled into bytecode, which is then interpreted by a virtual machine rather than being translated into native CPU instructions. This is the source of confusion, since 'compiled' often implies producing machine code directly, but Python's compilation step only produces an intermediate bytecode representation that an execution engine reads and executes. Developers untangling interpreter versus compiler debates can find deeper explainers like this on daily.dev.

What components does a minimal language implementation need?

A minimal language implementation needs a tokenizer, a parser, an abstract syntax tree (AST), a compiler that turns the AST into bytecode, and an execution engine that reads and runs the bytecode. The Calcium project demonstrates all of these pieces in roughly 300 lines of code, making it a compact reference for understanding how languages like Python are structured internally. Anyone building a toy language can browse implementation walkthroughs like this on daily.dev.

11K Impressions