Course Description: This course challenges you to implement an interpreter for an unfamiliar programming language (Lox) using a potentially new programming language (Rust), inspired by a book originally authored in a familiar language (Java).
General Overview
In university, you might have encountered assignments like "design a processor's instruction set," "build a Unix shell from scratch," or "solve the Dirac equation" on the first day. While some students shy away, others embrace the challenge. This course belongs to that challenging category.
You will dive into Robert Nystrom's "Crafting Interpreters" book and embark on implementing a lexer and a recursive descent parser. This will likely be your first experience with Rust, with challenges only intensifying thereafter.
Target Audience
This course is intended for seasoned developers eager to elevate their skills through intensive project work using a modern programming language. You might relate to one of these profiles:
- You've written some Rust and wish to move beyond basic examples with a complex, multi-component project.
- You have no Rust experience but are curious about it, confident in your compiler/interpreter skills, and ready for a new challenge.
- You lack both Rust and interpreter experience, but you have a free week and the willingness to face a profound challenge.
The course is akin to a marathon: you may question your decision mid-way, but completion brings immense satisfaction.
Learning Format
This is a week-long project-intensive course. Each morning begins with discussions on programming language design and Rust implementation. Most of the day is devoted to independent coding, punctuated by brief problem-solving and experience-sharing sessions.
Prerequisites
Participants should be comfortable with fundamental programming concepts such as expressions, operators, variables, control flow, functions, and classes. Experience with interpreter implementation is advantageous but not essential. While prior Rust knowledge is unnecessary, expect a steep learning curve with initial trial and error.
Curriculum
The goal is to navigate the first ten chapters of "Crafting Interpreters," developing an AST-walking interpreter for Lox. You'll explore key programming language implementation concepts:
- Scanning and lexical analysis
- Recursive descent parsing
- Program representation and AST construction
- Program execution
- Variables, scope, and environment
- Control structures like if, while, and for loops
- Functions, including higher-order functions and closures
Simultaneously, you'll delve into essential Rust development aspects:
- Project organization in multiple modules
- String handling
- Error handling with Option/Result
- Testing
- Algebraic data types (struct, enum)
- Recursive structures (trees, lists)
- Pattern matching
- Ownership and borrowing rules
- Interior mutability
The book provides necessary code snippets in Java, challenging you to translate and implement concepts in Rust. This translation makes course discussions particularly engaging and insightful.