Skip to main content
CF

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 Russian software engineer and educator focused on programming-language internals, compiler construction, JavaScript engine architecture, and the theoretical computer-science foundations underneath modern software development. His independent course catalog is one of the deepest sources of long-form material on language implementation available outside university CS programs.

His CourseFlix listing carries nine courses spanning parser combinators, interpreter construction, garbage-collection algorithm internals, the design of pattern-matching engines, and JavaScript object-model deep dives. Material is paid and aimed at engineers who want to understand how the languages they use every day actually work under the hood.

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

Related courses

Frequently asked questions

What prerequisites should I have before enrolling in this course?
You should have a basic understanding of how an interpreter works, including concepts like eval, closure, scope chain, and environment. If these terms are unfamiliar, it is recommended to first take the optional course 'Building an Interpreter from scratch'. No formal background in type theory is necessary.
What will I build by the end of this course?
By the end of the course, you will have built a static typechecker similar to those used in languages like Java and TypeScript. This typechecker will include features like type rules, variable typing environments, user-defined functions, and support for OOP concepts such as classes and inheritance.
Who is the target audience for this course?
The course is designed for engineers interested in building complex systems and understanding static analysis. It is also suitable for those who are developing their own programming languages, enjoy working with compilers, or want to deepen their knowledge of language design.
How does the scope of this course compare to others in the field?
Unlike many theoretical courses that focus on abstract mathematical concepts, this course provides a practical approach by allowing you to build a real static typechecker for a real language. It covers practical aspects of type theory that directly contribute to coding the typechecker.
What specific tools or platforms will I learn in this course?
The course will guide you through building a typechecker from scratch, focusing on the integration of type theory with practical coding. You will work with core programming constructs like S-expression parsing to AST, control flow management, closures, and generics.
What is not covered in this course?
The course does not cover advanced topics in type theory beyond what is necessary for building a static typechecker. It focuses on practical implementation rather than exploring the deeper theoretical aspects or formal proofs of type systems.
How might the skills from this course be applicable to other areas or careers?
The skills acquired in this course, such as understanding static type systems and their implementation, are valuable in careers focused on language design, compiler construction, and software engineering. Knowledge of typecheckers can enhance your ability to build robust, error-resistant software systems.