TP

Write your own tiny programming system(s)!

Wondering how to write your own programming language or an interactive programming system? In this course, you learn how fundamental programming language techniques, algorithms and systems work by writing their miniature versions. The course is made out of six modules, each looking at one langauge or system idea. It covers functional (TinyML and TinyHM), imperative (TinyBASIC), object-oriented (TinySelf) and end-user programming (TinyExcel).

This is a hands-on course. Each lecture starts with a few videos that provide background and explain key concepts. After watching the videos, the source code for each lecture gives you a basic structure of the language or system and tasks that you have to go through to implement the working language or system. There are also a few bonus problems for those interested in doing more!

The course uses the F# langauge, partly because I like F# and partly because F# is a great fit for the material. The course does not assume that you know F# already. Most of the tasks use simple algebraic data types (unions) and recursive functions and a few extra tricks are covered in the videos.

I ran this course in-person at Charles University in 2023/24 and 2025/26 and we're now using some of the ideas in the Principles of Programming Languages course.

Welcome: Write your own tiny programming system(s)!

A tiny programming system can be both educational tool and a research artifact to explore new ideas. I start by showing a few of my own research tiny systems and explaining the approach. I then explain why I talk about programming systems and not languages, before introducing F# through a couple of web-based demos.

Slides: Web-based or PDF format
Code: Demos from the lecture

TinyML: A tiny functional programming language interpreter

ML is a small functional-first programming language with origins in the 1970s that inspired F#. In the first lab, we write an interpreter for a small ML-like language. Implementing the interpreter is a good way to learn about basic aspects of the language such as variable scoping, lazy and eager evaluation and data types such as records and unions.

Slides: Web-based or PDF format
Code: Demos from the lecture, Tasks for the lab

TinyBASIC: A tiny interactive imperative programming system

Looking at BASIC is perhaps unexpected, but it shows two new ideas. First, you'll learn how to manage mutable state and how to implement control flow constructs such as goto. Second, we will also look at BASIC as an interactive programming system where programmers can edit input using line numbers that were used by BASIC on microcomputers such as Commodore 64.

Slides: Web-based or PDF format
Code: Demos from the lecture, Tasks for the lab

TinyHM: Writing the Hindley-Milner type inference algorithm

Languages like ML and F# are statically typed, but you do not have to write types explicitly. They are inferred using a type-inference algorithm. In this lab, we revisit our previous TinyML implementation and implement the classic Hindley-Milner algorithm to automatically infer types for variables and functions in the code. We'll also see how this relates to error conditions in our interpreter!

Slides: Web-based or PDF format
Code: Demos from the lecture, Tasks for the lab

TinyProlog: Writing tiny logic programming language

In logic programming languages like Prolog, programs are written as a database of facts or derivation rules and evaluation of a program is inference using those rules. In this lab, you'll understand what exactly this means by writing a small Prolog interpreter. You'll also see that the core logic of the algorithm is remarkably similar to our earlier type inference logic!

Slides: Web-based or PDF format
Code: Demos from the lecture, Tasks for the lab

TinySelf: Writing an object-oriented programming system

Self is a minimalistic object-oriented programming system that uses prototype-based model. Thanks to the unified design where everything is an object, it is a fun programming system to implement on your own! In the lab, you'll learn about prototypes, method lookup and activation records — ideas that are behind many object-oriented systems.

Slides: Web-based or PDF format
Code: Demos from the lecture, Tasks for the lab

TinyExcel: Implementing reactive graph-based computations

Some say that Excel is the most widely used programming language. Whether you believe this or not, it is a great way to explore writing reactive programming system where outputs recompute when inputs change. You'll also learn about some powerful end-user programming tricks such as the "drag down" operation that extends a formula to apply over a region of cells.

Slides: Web-based or PDF format
Code: Demos from the lecture, Tasks for the lab

Published: Sunday, 7 December 2025, 12:00 am
Author: Tomas Petricek
Typos: Send me a pull request!