Week 1 of 125
Crafting Interpreters, chapters 1, 2 and 3
Sign up or sign in to tick these off and give this week a due date.
-
Read Ch 1: Introduction
Why build a language, who the book is for, and the plan: two interpreters for the same small language, Lox. Bob explains the book's style of showing every line of code.
Time About 2 hours this week
Why it matters
Sets expectations. You are about to write every line of two real interpreters yourself, which is the best way to stop seeing compilers as magic.
How to approach it
Read it in one sitting. Set up your environment now: a JDK, a C compiler, an editor and your lox repo. Do not skip the setup challenges; they are the real homework this week.
Challenges
3 challenges at the end of the chapter.
Challenge 1 is a reading exercise about little languages in the book's own build system; worth 10 minutes. Challenges 2 and 3 (hello world in Java, then a doubly linked list in C) are effectively your setup check. If the C linked list feels hard, spend extra time on pointers now; clox will demand it.
Traps
- Skipping the C linked-list challenge. It is a preview of exactly the pointer skills clox needs from chapter 14.
- Overthinking editor and build setup. A Makefile or a single javac command is enough for jlox.
-
A tour of the parts of a language implementation: scanning, parsing, static analysis, intermediate representations, optimization, code generation, virtual machines and runtimes, plus the shortcuts and alternate routes like transpilers and JITs.
Time About 2 hours this week
Why it matters
This map tells you where every later chapter fits. It is also the vocabulary you need to read about any real compiler or VM.
How to approach it
Read it once now, then come back to it when you start clox in week 8; it will make more sense the second time. Sketch the mountain diagram from memory afterward.
Challenges
3 challenges at the end of the chapter.
Challenge 1 (find the scanner and parser in a real open source implementation) is the most valuable; pick a language you use and actually open the source. The other two are think-about-it questions.
Traps
- Trying to memorize every term. You will learn them by building them.
-
An informal tour of Lox: dynamic typing, automatic memory management, the data types, expressions, statements, variables, control flow, functions, closures, classes and inheritance.
Time About 2 hours this week
Why it matters
You need to know the target language before you implement it. Lox is small but has real closures and classes, so it exercises the hard parts.
How to approach it
Read it, then write a few Lox programs in a text file now (you can run them later with your own interpreter, or try the reference build from the repo). Keep a list of questions about the semantics; the book answers most of them later.
Challenges
3 challenges at the end of the chapter.
Challenge 1 (write and run sample programs) is good to do once you have an interpreter. Keep your answer to challenge 3 (features you would add) in a notes file: chapter 13 asks you to implement one of them.
Traps
- Assuming Lox behaves like JavaScript or Python in edge cases. Check the chapter.
-
NeetCode LeetCode: 2 NeetCode 150 problems
Two problems from the NeetCode 150, in order. One box for the pair.