Skip to main content
CourseFlix

Building a Typechecker from scratch

2h 16m 15s
English
Paid

Static typecheckers help you catch errors early and keep your code safe. They also make debugging easier. In this course, you see how a typechecker works and how you can build one step by step.

You may ask: What is type checking? What is type inference? How do type rules work? Is my language weak or strong? And how do I build a typechecker at all? This course gives clear answers with a full hands-on build.

Many books focus on theory and treat types as abstract math. This course takes a more direct path. You build a real static typechecker for a real language in a few hours. Every idea comes with clear code and live examples.

You start coding in the first lecture. You learn how a typechecker fits into a language stack and why it helps you grow as an engineer.

What You Learn

You build a static typechecker similar to the ones used in Java, TypeScript, and other typed languages. You learn core ideas from type theory only when they help you code the next step.

Prerequisites

You do not need any formal background in type theory. But you should know how an interpreter works. The optional course Building an Interpreter from scratch helps with this.

If you understand terms like eval, closure, scope chain, and environment, you are ready to start. If not, take the interpreter course first.

Who This Course Is For

This course is for engineers who want to build complex systems and learn how static analysis works. It is also for anyone who builds a language, enjoys compilers, or wants a clear view of type systems.

Tools You Use

You do not need a special “types-first” language to build a typechecker. You use plain JavaScript to keep the ideas simple. The logic then maps cleanly to TypeScript, Rust, OCaml, Python, C++, or any other language you prefer.

How You Learn

You write each part of the typechecker yourself. The video lessons show the full source code, but the repo includes tasks marked with /* Implement here */. You fill these in during the course so you understand every detail.

About the Author: Dmitry Soshnikov

Dmitry Soshnikov thumbnail
Dmitry Soshnikov is a software engineer, lectures on various topics of computer science. He is passionate about education and has a strong focus on high quality educational content: concise and clear animated lectures with real-time notes.

Watch Online 20 lessons

This is a demo lesson (10:00 remaining)

You can watch up to 10 minutes for free. Subscribe to unlock all 20 lessons in this course and access 10,000+ hours of premium content across all courses.

View Pricing
0:00
/
#1: Introduction to Type theory and checking
All Course Lessons (20)
#Lesson TitleDurationAccess
1
Introduction to Type theory and checking Demo
19:39
2
Typing Numbers and Strings | Testing
04:18
3
Math binary operations | String concat
06:46
4
Variables and Typing Environment, Р“
08:17
5
Blocks and Local scope
06:55
6
Parsing: S-expression to AST
07:31
7
Control flow: If and While expressions
07:25
8
User-defined functions | Local environments
09:16
9
Function calls | Built-in functions
04:42
10
Closures | Recursive calls
05:12
11
Lambda functions and IILE | Syntactic sugar
04:30
12
Declaring new types | Type aliases
03:54
13
OOP | Classes
06:40
14
OOP | Instances
03:51
15
Super calls | Inheritance
02:49
16
Union type
06:02
17
Union | Type narrowing
07:24
18
Generics | Function declarations
06:51
19
Generics | Function calls
07:09
20
Final executable
07:04
Unlock unlimited learning

Get instant access to all 19 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.

Learn more about subscription