The concept of a stack is crucial and at the heart of programming. It’s fundamentally essential down at the very lowest-levels of programming (I’m referring to next-to-machine level), and is used everywhere even in today’s highest-level software projects.
What does it mean to program with stacks?
If you had a deck of cards in your hand and started laying them on the table on top of each other, you’d slowly build up a stack of cards. If you then only allowed yourself to remove cards one at a time from that stack, you’d be following the rules of a programming stack.
Consider that the first card you place on the table will be the last one you’re able to remove (not until all subsequent cards are removed). This means cards that are first in are removed last. In computer programming lingo this is called “First In, Last Out, or FILO. Interestingly, if you placed cards in order from 10 to Ace onto the stack, when you pull them off the order will be reversed. More on that later.
In Part 2 I will discuss the history of the stack and why it’s important in low level programming.