Lecture notes · The Missing Semester · Lecture 7

Debugging and Profiling

MIT 6.NULL The Missing Semester of Your CS Education, lecture 7, explained in plain English

Want this lecture to stick? In LessonBound you get checked practice questions for every part, can ask about anything you don't get, and can listen with your screen off. Free, no ads.

Learn this lecture free

Watch or read the original lecture: MIT OpenCourseWare.

Part 1

This part explains several ways to find bugs in code, from printing and logging to debuggers and static analysis, and it does not cover profiling.

Key ideas

Words to know

severity levels
Labels such as INFO, WARN, and ERROR that show how serious a log message is, so you can filter out the less important ones.
debugger
A tool that lets you pause a running program, step through it slowly, and check what its variables hold.
breakpoint
A marked line in your code where the program automatically pauses so you can look around.
static analysis
Checking code for problems by reading it with rules, without running it.

Example

Think of a video that you can pause and advance one frame at a time. A debugger works the same way for a program: you can stop it at a chosen moment, go forward one step, and look at what everything is set to. Printing values is more like taking a few still photos along the way.

3 checked practice questions for this part are in the app.

Part 2

This part shows how to find bugs and slow spots in code, using tools that check code without running it and tools that measure how long each part takes.

Key ideas

Words to know

static analysis
Checking code for mistakes by reading it, without actually running the program.
linter
A tool that checks code for bugs, style problems, or unsafe habits and reports them, often right inside your editor.
profiler
A tool that runs your program and measures where it spends its time or resources, so you know which parts to speed up.
sampling profiler
A profiler that checks what the program is doing at regular short intervals, instead of recording every single function call.

Example

Think of proofreading a letter before you mail it: you can catch a misspelled name just by reading it, without sending it first. Timing a recipe works the same way: you check how long each step takes, so you know which step is eating most of your evening.

3 checked practice questions for this part are in the app.

Part 3

This part teaches how to find out where a program spends its time and memory, using tools that measure each line, show system events, and display results in easy-to-read pictures.

Key ideas

Words to know

garbage collected
When a language cleans up memory that the program no longer needs, so the programmer does not have to free it by hand.
memory leak
A bug where a program keeps memory it no longer needs, so the memory is never released.
flame graph
A picture that shows which functions a program calls and how much time each one takes, with the wider blocks taking more time.
black box
Something you use without looking inside. You judge it only by what goes in and what comes out.

Example

Think of a road trip that took six hours. Instead of guessing, you write down how long each stop took, and you find that the lunch stop took four hours. A line profiler does the same thing for a program, showing which line took most of the time.

3 checked practice questions for this part are in the app.

← Lecture 6: Version Control (Git) · Lecture 8: Metaprogramming →

Notes written by AI (Claude) from the lecture's official transcript, so check anything important against the lecture. MIT CSAIL · CC BY-NC-SA 4.0 · not affiliated with or endorsed by MIT. These notes are shared under the same license.

LessonBound · Free lecture notes · Privacy · Terms · New York