Skip to main content

Building an Interpreter from scratch

2h 59m 53s
English
Paid

Course description

How programming languages work under the hood? What’s the difference between compiler and interpreter? What is a virtual machine, and JIT-compiler? And what about the difference between functional and imperative programming? There are so many questions when it comes to implementing a programming language! The problem with “compiler classes” in school is they usually are presented as some “hardcore rocket science” which is only for advanced engineers.

Read more about the course

Moreover, classic compiler books start from the least significant topic, such as Lexical analysis, going right away deep down to the theoretical aspects of formal grammars. And by the time of implementing a first Tokenizer module, students simply lose an interest to the topic, not having a chance to actually start implementing a programing language itself. And all this is spread to a whole semester of messing with tokenizers and BNF grammars, without understanding an actual semantics of programming languages.

I believe we should be able to build and understand a full programming language semantics, end-to-end, in 4-6 hours — with a content going straight to the point, showed in live coding session as pair-programming, and described in a comprehensible way.

In the Essentials of Interpretations class we focus specifically on runtime semantics, and build a interpreter for a programming language very similar to JavaScript or Python.

Implementing a programing language would also make your practical usage level of other programming languages more professional.

Who this class is for?

This class is for any curious engineer, who would like to gain skills of building complex systems (and building a programming language is really a pretty advanced engineering task!), and obtain a transferable knowledge for building such systems.

If you are interested specifically in compilers, interpreters, and source code transformation tools, then this class is also for you.

The only pre-requisite for this class is basic data structures and algorithms: trees, lists, traversal.

What is used for implementation?

Since we build a language very similar in semantics to JavaScript or Python (the two most popular programming languages today) we use specifically JavaScript — its elegant multi-paradigm structure which combines functional programming, class-based, and prototype-based OOP fits ideal for that.

Many engineers are familiar with JavaScript so it should be easier to start coding right away. However in implementation we don’t rely on too specific to JS constructs, and the code from the course is easily portable to TypeScript, Python, Java, C++, Rust, and any other language of your taste.

What’s specific in this class?

The main features of these lectures are:

  • Concise and straight to the point. Each lecture is self-sufficient, concise, and describes information directly related to the topic, not distracting on unrelated materials or talks.

  • Animated presentation combined with live-editing notes. This makes understanding of the topics easier, and shows how (and when at time) the object structures are connected. Static slides simply don’t work for a complex content.

  • Live coding session end-to-end with assignments. The full source code, starting from scratch, and up to the very end is presented in the class

What is in the course?

The course is divided into four parts, in total of 18 lectures, and many sub-topics in each lecture. Please address curriculum for detailed lectures descriptions.

PART 1: COMPILERS CRASH COURSE

In this part we describe different compilation and interpretation pipelines, see the difference between JIT-compilers and AOT-compilers, talk about what is a Virtual machine and Bytecode-interpreter, and how it difference from an AST-interpreter, show examples of native code, and LLVM IR, and other topics.

PART 2: INTERPRETERS: BASIC EXPRESSIONS AND VARIABLES

In this part we start building our programming language, and consider basic expressions, such as numbers, strings, talk about variables, scopes, and lexical environments, control structures, and touching parser generator.

PART 3: FUNCTIONS AND FUNCTIONAL PROGRAMMING

In this part we start talking and implementing function abstraction, and function calls. We describe concept of closures, lambda function, and IILEs (Immediately-invoked lambda expressions). In addition, we touch topics of Call-stack, recursion, and syntactic sugar.

PART 4: OBJECT-ORIENTED PROGRAMMING

The final part of the course is devoted to the object-oriented support in our language. We describe the class-based, and prototype-based approaches, implement concept of classes, instance and modules.

Requirements:
  • Basic data structures and algorithms
  • Graphs, trees, traversal
Who this course is for:
  • Curious engineers who want to know and understand how programming languages work under the hood

What you'll learn:

  • Build a programing language from scratch
  • Interpreters and Compilers
  • AOT, JIT-compilers and Transpilers
  • AST-interpreters and Virtual Machines
  • Bytecode, LLVM, Stack-machines
  • First-class functions, Lambdas and Closures
  • Call-stack and Activation Records
  • OOP: Classes, Instances and Prototypes
  • Modules and Abstractions

Watch Online

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

Comments

0 comments

Want to join the conversation?

Sign in to comment

Similar courses

A/B Testing for Data Science

A/B Testing for Data Science

Sources: LunarTech
Stand out in the competitive job market in the field of data science. Master A/B testing - a skill highly valued by employers. Learn...
1 hour 47 minutes 56 seconds
Computer Science Fundamentals

Computer Science Fundamentals

Sources: Andreas Kretz
As in any field, strong fundamental knowledge forms the foundation for everything else. That is why this course is your first step on the path to a profession..
1 hour 30 minutes 17 seconds
Introduction to Networking

Introduction to Networking

Sources: zerotomastery.io
Discover the basics of computer networks and how they impact everyday life. Perfect for beginners eager to understand networking with zero prior knowledge.
1 hour 49 minutes 15 seconds
The Complete French Course

The Complete French Course

Sources: Alexa Polidoro
Learn from a world-renowned French teacher! This course is designed to take you from your first words to fluency in the language.
Advanced Prompt Engineering

Advanced Prompt Engineering

Sources: DAIR.AI
This course is dedicated to advanced methods in Prompt Engineering for large language models (LLMs) and their effective application in various scenarios.
1 hour 23 minutes 57 seconds