Syllabus
This is the material planned for this quarter.
All credit goes to Ryan Eberhardt, Armin Namavari, and Julio Ballista for their work developing and refining the contents of this course in the past. I’ll be using their materials with minimal modification.
Lecture material
Memory safety and Rust basics
- What is memory safety? Why is it an issue in C and C++?
- What tools can we use to find problems in C/C++ code?
- How do alternative programming languages help us to avoid making mistakes in programs?
- Rust’s memory model: ownership, lifetimes, references
- RAII in C++, and how it compares to Rust
How do you architect good code?
- Pitfalls of
null;OptionandResultin Rust - Enums in Rust
- Different approaches to abstraction: traits vs object-oriented programming
Avoiding multiprocessing pitfalls
- Managing pipes: How do we avoid resource leaks?
- Signal handling: Why is it so hard to get right? How can we do better?
Avoiding multithreading pitfalls
- Revisiting memory safety in the context of threads
- How can we use Rust’s memory model to prevent race conditions? Where might it not save you?
- Mutexes, arc pointers, semaphores, condition variables
- Message passing as an alternative to traditional shared memory
Putting this all into practice: Networked systems
- Handling and sending HTTP requests
- Implementing a threaded server
- Load balancing, failure handling in distributed systems
- Nonblocking I/O; async/await and futures in Rust
Projects
Simple debugger: Have you ever wondered how GDB works under the hood? You’ll use multiprocessing skills you’ve acquired from CS 110 and CS 110L to implement a simple version of your own!
High-performance server: Optimizing for speed is a key task in large distributed systems. Amazon found that a 0.1s increase in latency reduced sales by 1%, and Google found that an 0.4s increase in latency reduced searches by 0.7%. In this project, you’ll use a variety of techniques from CS 110 and CS 110L to build a fast but robust web server.
Schedule
Updated 2/9/2022
Week 1:
- Lecture 1: Welcome! And motivation for the class.
- Lecture 2: Program analysis: static and dynamic analysis, shortcomings of existing tools
Week 1 exercise: Get familiar with some common C/C++ program analysis tools, including what they don’t catch.
Week 2:
- Lecture 3: Memory safety and memory ownership
- Lecture 4: Memory ownership and intro to Rust
Week 2 exercise: “Hello World!” program to get familiar with basic Rust syntax
Week 3:
- No class Monday (MLK day)
- Lecture 5: Error handling in C, C++, and Rust
Week 3 exercise: Error handling and I/O in Rust: build a basic tool to inspect file descriptors (concurrent with CS110 concepts)
Week 4:
- Lecture 6: Custom types in Rust and some code examples
- Lecture 7: More custom types in Rust and some code examples, + garbage collection in Rust and other languages
Week 5:
- Lecture 8: Object-oriented programming in C++ and in Rust; inheritance, traits, and a code example.
- Lecture 9: Generics in Rust (and why they’re useful for write robust code) + intro to multiprocessing
Week 5 exercise: Practice with traits & generics
Project 1 released: Build a debugger in Rust. Working in groups is encouraged! (This may seem intimidating, but we promise that you will have all of the tools to do it.)
Week 6:
- Lecture 10: Multiprocessing - common pitfalls (concurrent with CS110 topics) + how Rust does multiprocessing. Project 1 walkthrough.
- Lecture 11: Multiprocessing II (pipes and browsers)
Week 7:
- Lecture 12: In-class project 1 work
- Lecture 13: Multithreading Intro
Week 7 exercise: “simple farm, but with multithreading” (similar to CS110 assignment)
Project 2 released: Build your own load balancer for a distributed system. (Again, this may sound intimidating, but it’s really not! And you’re invited to work in groups if you’d like to.)
Week 8:
- No class Monday (president’s day)
- Lecture 14: More multithreading, with code examples
Week 9:
- Lecture 15: In-class project 2 work time + Q&A
- Recorded video: project 2 walkthrough
- Lecture 16: TBD (likely “channels” communication abstraction)
Week 10:
- Lecture 17: TBD (likely event-driven programming)
- Lecture 18: Closing & Key Takeaways