Building an Interpreter from scratch

Semantics of programming languages

4.91 (239 reviews)
Udemy
platform
English
language
Programming Languages
category
Building an Interpreter from scratch
1,059
students
3 hours
content
Sep 2020
last update
$59.99
regular price

What you will 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

Why take this course?

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.

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.

Note: we want our students to actually follow, understand and implement every detail of the interpreter themselves, instead of just copy-pasting from final solution. The full source code for the language is available in video lectures, showing and guiding how to structure specific modules.


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 video lectures class. In the course we implement a full AST interpreter for our programming language.


Reading materials

As further reading and additional literature for this course the following books are recommended:

  • Structure and Interpretation of Computer Programs (SICP) by Harold Abelson and Gerald Jay Sussman

  • Programming Languages: Application and Interpretation (PLAI) by Shriram Krishnamurthi


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.


I hope you’ll enjoy the class, and will be glad to discuss any questions and suggestion in comments.

- Dmitry Soshnikov

Reviews

Ross
November 6, 2023
I really think this kind of course is a good way to go from self-taught programmer to a more professional understanding of programming.
Sulagno
October 10, 2023
I am not able to understand where I made the mistake because it's been 4 hours I have been trying to fix a bug, because of lack of source code I can't even understand what am I doing wrong, it is super frustrating. Please provide the source code I am begging, only for a part I am requesting my code for resolve is not working even though I am doing the exact same thing and I checked the test case as well, and if the blocks thing doesn't work the entire code starts to break down, please just provide me the code till blocks because it's been half a day, I want to finish this course and get on with interview prep as well
Imanol
October 1, 2023
The curse is great. Being new to the compiler/interpreter world you learn a lot but I have missed some type of solutions. Sometimes during lectures, the code is changed and it is not clarified, you then have to go through a debuging process and figure out what is incorrect. Overall good curse!
Belek
July 23, 2023
Dmitry Soshnikov's course "Building an Interpreter from Scratch" is an exceptional educational resource that makes interpreter construction both accessible and engaging. The use of test-driven development enhances understanding and mirrors real-world software development processes, providing students a practical and robust framework for learning. Soshnikov's clear and methodical teaching style complements the well-structured, comprehensive material, resulting in an optimal balance of theory and practice. Ideal for anyone interested in delving into the complexities of interpreters, this course stands out for its effective approach to teaching a challenging computer science concept. Highly recommended!
Christopher
May 23, 2023
As a C/C++ developer who never got a chance to take a compilers course in my studies, this was a very valuable resource and great use of time. The only reason I marked it down to 4.5 stars is that at times it was difficult to follow the live coding video (went too fast, or skipped over some minor detail required to get it to really run). I think this could be fixed by providing folders in the git repository for each step in the class (section 3.11, section 4.15, etc) that are the starting points of the code. This way you can do a quick diff to see what you missed if your code still isn't working. Regardless, a great resource and I recommend to experienced and new developers alike.
Gustavo
March 18, 2023
One of the best courses I watched, no matter the content itself, but the course itself is easy to follow and really good for understanding.
Jordan
February 17, 2023
It was interesting to see the variety of topics covered and it was educational. Sometimes certain things went a little quickly and I noticed the sample programs on screen sometimes changed mid-way without mention of correcting them. I had to really look at the braces at times.
Joao
December 4, 2022
Easily one of the most interesting and mind blowing courses I've seen. It's all very hands-on and thoroughly explained step by step. However, be prepared to debug your own code, as the source code is only partially available and you are expected to follow along. This is on purpose and, while challenging, adds a lot of value as it forces you to understand the lesson. Dmitry is also quite active and helpful in the Q&A.
Maxime
October 16, 2022
Really great course! A bit fast-paced for non-confirmed devs but the instructor is clear and really makes you understand even harder concepts. The missing half star is due to the lack of assignments solutions. It's a good thing because you are not tempted to bypass reflexion time but after implementation you are not really sure if what you've done is correct / optimized. I will gladly join the next course, which is already bought!
Evgeny
October 9, 2022
Overall it was great so I will only concentrate on the negative sides. I was using Python to implement this interpreter and I had to overcome some difficulties because of my choice. First, your syntax tool you suppose us to use to parse an AST is not so good at being language agnostic. I had pretty annoying experience edditing generated Python code I don't understand because it messed up with JS constructions somehewe. Your tool was adding semicolons and sometimes using JS operators (e.g. Number(x) to convert str to int). And in general code that you writing is not always so easy portable on other languages, so I guess it would be better if at the beginning you will recommend to use Node JS the same way as you do. But the material was awesome! Thanks.
Brandon
September 11, 2022
Overall, excellent presentation. The class teaches you every bit as much about program design and TDD as it does about AST interpreters. One review remarked that one should be proficient in debugging, and that's true, so it does add a certain drag to the course, hence the minus half-a-star (starting at the implementation of 'super', I couldn't get the tests to pass; it looked like the subsequent tests didn't have the super class in the environment. Same situation with modules.) However, overall, it's definitely possible to grasp how everything works at a high enough level that you could make all these ideas your own somehow. So overall, I'm pleased :)
Mattia
March 31, 2022
There are some typos here and there which end up consuming quite a lot of time when following a long with the code. Other than that, all good.
Charles
September 28, 2021
The instructor has a strong grasp of the concepts and a straightforward method of explaining them. The prospective student should be aware that full source code is not available and that knowledge of a debugger and debugging techniques will be required to complete the course.
VIjay
September 25, 2021
This is one of the best course I have ever gone through. The amount of knowledge condensed in this is way too much. Don't rush to finish this course instead try to sink in whatever you are learning. All these lessons are transferrable in your work and language you will be working on throughout your career. Thanks a lot Dmitry for making all these courses. I have bought all of them :-D
Dmitrij
April 13, 2021
Very clear and well paced course. Some smaller issues in the presented code but overall very pleasant to follow along.

Charts

Price

Building an Interpreter from scratch - Price chart

Rating

Building an Interpreter from scratch - Ratings chart

Enrollment distribution

Building an Interpreter from scratch - Distribution chart
2845910
udemy ID
3/2/2020
course created date
3/21/2020
course indexed date
Bot
course submited by