I heard this excellent analogy to explain RAM in computers a long time. It really stuck with me and I’ve used this analogy many times to make the concept easier to understand. My brother also remembered this and wrote about it in Persistence of a Desk.
The link above is dead, so here is the content:
Imagine yourself sitting at a desk with a filing cabinet behind you.
Whenever you’re working on something there’s only so much information that you can keep on your desk at any one time. If you run out of space, you’ll be forced to put something back into the cabinet before you can bring something else out to work with.
As such, the smaller your desk, the more trips you’ll have to make back and forth between the desk and the filing cabinet to store and retrieve information. Get a bigger desk and you can work with more information simultaneously.
Now imagine the desk is the memory in your computer and the cabinet is the hard drive. When it needs access to information that isn’t in memory, it needs to get it from the hard drive. We even have Virtual Memory (VM) which allocates a piece of the hard drive specifically for that purpose.
So far I think this is a pretty well known analogy. I did a quick google search and came up with this.
But I like this analogy because you can take things so much further with it. Got a virus? Imagine a (alright, I admit it would have to be somehow self-replicating) cat that’s constantly jumping on your desk interrupting your work. Stuff it in the cabinet and it’s harmless, unless you activate (run) it, thus putting it back on your desk.
Applications give you work by placing it on the desk. Now naturally they can’t place the work just anywhere, so we have an overseer that allocates space for each application depending on its needs.
Unfortunately on the odd occasion applications will try to place work in areas that don’t belong to them, which naturally will cause a conflict (MS Word places information in an area that belongs to Excel. Excel gets pissed and beats the crap out of Word, which has to be taken to hospital. Finally, Excel gets arrested for assault).
Those were the old days. Nowadays we employ bouncers. As soon as Word is spotted trying to steal Excel’s spot, it gets kicked out. Word crashes, but Excel survives.