"You've been using a stack since your very first program — you just couldn't see it. Every function call you make pushes onto one, and every return pops off it."
Last In, First Out
A stack has one rule: the last thing you put in is the first thing you take out. push adds to the top, pop removes from the top, peek looks at the top without removing — all O(1), because the "top" never requires shifting anything. Think of a stack of plates: you add and take from the top, and reaching the bottom one means clearing everything above it first.
The Call Stack: a Stack You Already Depend On
Here's the part that reframes everything: the call stack — the mechanism that runs your functions — is literally a stack. When function A calls B, a frame for B (its local variables, its return address) gets pushed on top of A's frame. When B returns, its frame pops, and control falls back to exactly where A left off. Nested calls stack up; returns unwind in reverse order. This is why recursion depth equals stack depth (the space cost from the Complexity track), and why infinite recursion throws RecursionError — you've literally overflowed the call stack. You weren't just learning a data structure; you were learning the thing that's been executing all your code.
Where Stacks Shine: Matching and Nesting
Any problem about nesting or matching is a stack problem. Balanced parentheses, valid HTML/XML tags, matching brackets in code, evaluating arithmetic expressions, the undo button (each action pushed; undo pops the latest) — all stacks. The pattern: push when you open something, pop when you close it, and check that what you popped matches what's closing. If the stack is empty when you need to pop, or non-empty at the end, the nesting was broken. We'll see this exact pattern again as the engine of depth-first search.
Pippa's Confession
push and pop by hand. My infinite-recursion crashes suddenly made physical sense: I'd been pushing frames forever and overflowing a real stack. The abstraction I was studying turned out to be the floor I'd been standing on the whole time.