Skip to main content

Building an Interpreter from scratch

2h 59m 53s
English
Paid

Understand the fundamentals of programming languages and dive deep into how they operate beneath the surface. Explore the distinctions between compilers and interpreters, learn about virtual machines and JIT-compilers, and comprehend the differences between functional and imperative programming. Many questions surface when implementing a programming language, and traditional "compiler classes" often present them as complex, advanced topics — something only for expert engineers.

Course Description

Traditional compiler textbooks often start with less engaging topics like Lexical Analysis and delve into theoretical aspects of formal grammars. By the time students implement their first Tokenizer module, they may lose interest without having the chance to create a full programming language. This course takes a different approach, focusing on building a comprehensive understanding of programming language semantics in just 4-6 hours using a practical, live coding session format.

In the Essentials of Interpretations class, we concentrate specifically on runtime semantics and create an interpreter for a language similar to JavaScript or Python. By implementing a programming language, you'll enhance your understanding and application of other programming languages.

Who is this class for?

This class suits curious engineers eager to learn about building complex systems, such as programming languages. If you're interested in compilers, interpreters, and source code transformation tools, this course is for you. The only prerequisite is a basic understanding of data structures and algorithms — trees, lists, and traversal.

Tools and Implementation

We implement a language with semantics akin to JavaScript or Python, using JavaScript for its versatile, multi-paradigm structure, suitable for this endeavor. While JavaScript is prevalent and easy to pick up, the code from this course is transferable to TypeScript, Python, Java, C++, Rust, and many more languages.

Course Highlights

  • Concise and to the point lectures. Self-contained and focused on relevant topics without digressing into unrelated discussions.
  • Animated presentations and live-editing notes. Enhance comprehension and demonstrate the interconnectedness of object structures, more effectively than static slides.
  • Comprehensive live coding sessions. From the basics to the final implementation, experience coding through assignments and complete resources provided in the class.

Course Structure and Content

The course consists of four parts, spanning 18 lectures with various sub-topics. Refer to the curriculum for detailed descriptions of each lecture.

Part 1: Compilers Crash Course

This section explores various compilation and interpretation pipelines, comparing JIT-compilers with AOT-compilers, and discussing Virtual machines, Bytecode-interpreters, AST-interpreters, and examples of native code and LLVM IR.

Part 2: Interpreters - Basic Expressions and Variables

Begin building the programming language by handling basic expressions like numbers and strings, understanding variables, scopes, lexical environments, control structures, and parser generators.

Part 3: Functions and Functional Programming

Explore and implement function abstractions and calls, understanding closures, lambda functions, and IILEs. This section also covers the Call-stack, recursion, and syntactic sugar.

Part 4: Object-Oriented Programming

Focus on incorporating object-oriented support in our language, discussing class-based and prototype-based approaches, and implementing concepts like classes, instances, and modules.

Course Requirements

  • Basic understanding of data structures and algorithms
  • Familiarity with graphs, trees, and traversal

Who Should Enroll?

  • Engineers curious about the inner workings of programming languages

What You'll Learn

  • Build a programming language from scratch
  • Understand Interpreters and Compilers
  • Differentiate AOT, JIT-compilers and Transpilers
  • Work with AST-interpreters and Virtual Machines
  • Explore Bytecode, LLVM, and Stack-machines
  • Master First-class functions, Lambdas, and Closures
  • Understand the Call-stack and Activation Records
  • Implement OOP: Classes, Instances, and Prototypes
  • Create Modules and Abstractions

About the Authors

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.

udemy

udemy thumbnail
By connecting students all over the world to the best instructors, Udemy is helping individuals reach their goals and pursue their dreams. Udemy is the leading global marketplace for teaching and learning, connecting millions of students to the skills they need to succeed. Udemy helps organizations of all kinds prepare for the ever-evolving future of work. Our curated collection of top-rated business and technical courses gives companies, governments, and nonprofits the power to develop in-house expertise and satisfy employees’ hunger for learning and development.

Watch Online 18 lessons

This is a demo lesson (10:00 remaining)

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

View Pricing
0:00
/
#1: Parsers, ASTs, Interpreters and Compilers
All Course Lessons (18)
#Lesson TitleDurationAccess
1
Parsers, ASTs, Interpreters and Compilers Demo
12:08
2
AST Interpreters and Virtual Machines
12:02
3
Compilers: AOT, JIT, Transpiler
12:19
4
Eva programming language
11:12
5
Self-evaluating expressions
07:03
6
Variables and Environments
13:07
7
Blocks: expression groups and Nested Scopes
11:56
8
Control flow: If and While expressions
06:09
9
Back to parsers: S-expression to AST
09:44
10
Built-in and Native functions
06:54
11
User-defined functions, Activation Records and Closures
13:57
12
Lambda functions and Functional programming
06:33
13
Call-stack and Recursive calls
09:37
14
Syntactic sugar: Switch, For, Inc, Dec operators
08:56
15
Object-oriented Eva: Classes
10:50
16
Class inheritance and Super calls
04:24
17
Code isolation: Modules and Imports
09:35
18
Final executable and specification
13:27
Unlock unlimited learning

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

Learn more about subscription