Grasping the importance of garbage collection
In the beginning, programs were small, and the static allocation of memory was decided when a program was designed. The code was not that complicated, and programmers could lay out all the memory that they were going to use during the entire program as a set of global variables. Life was good. A lot of programmers would prefer to just stick with static allocation, and in certain niche application domains, that remains feasible.
For the rest of us, Moore’s Law happened, and computers got bigger. Data got bigger. Customers started demanding that programs handle arbitrary-sized data instead of accepting the fixed upper limits inherent in static allocation. Programmers invented structured programming and used function calls to organize larger programs in which most memory allocation was on the stack.
A stack provides a form of dynamic memory allocation. Stacks are great because you can allocate a big chunk of memory when a function...