You've typed for an hour, the lights flicker, the computer goes dark, and when it comes back your work is gone. Yet every photo you saved last year is still there. Same machine, same power cut, very different outcomes. The reason is that a computer has two completely different kinds of memory, built for two different jobs: RAM and storage. Once you see how they split the work, "loading", "saving" and "why is my laptop slow" all start to make sense.
Picture yourself working in an office. You have a filing cabinet, which is big, holds everything you own, and keeps it safe overnight. And you have a desk, which is small but right in front of you. You can't write on a document while it's inside the cabinet; you take it out, put it on the desk, and work on it there.
The part of the computer that actually does the work, the CPU (central processing unit, or processor), is the person sitting at the desk. It only works on what's on the desk. Anything in the cabinet has to be fetched first.
"Memory" is a confusing word because people use it for both. When a shop says a phone has "128 GB of memory", they almost always mean storage. When a programmer says "this program uses too much memory", they mean RAM.
This little simulator has a cabinet (storage) and a desk with just three slots (RAM). Open something, edit the essay, save or don't, then pull the plug and see what survives. Try opening the big game while the essay is open, too. Watch the two copies of essay.txt.
Desk & filing cabinet simulator
Big and slow. Everything you've installed or saved lives here.
Small and fast. Only what's open right now. Needs power to remember.
A few things to notice in there:
The common kind of RAM, called DRAM (dynamic RAM), stores each bit (each 0 or 1) as a tiny electrical charge in a microscopic component called a capacitor. Charged means 1, empty means 0. These capacitors are so small that the charge leaks away within a fraction of a second, so the memory chips constantly re-read and re-write every bit to top it up, a process called refreshing. Each row of memory gets refreshed roughly every 64 milliseconds, around the clock, as long as the machine is on.
Cut the power and the refreshing stops. Within moments the charges fade and the bits are gone. Nobody designed RAM to forget as a feature; it's the price of a design that is cheap enough per bit and fast enough to keep up with the CPU.
Storage works differently. An SSD (solid-state drive) traps electrons inside insulated cells of flash memory, the same kind used in USB sticks and phones, where they stay put for years without power. An older HDD (hard disk drive) stores bits as tiny magnetised spots on a spinning metal platter, and magnetism doesn't need electricity to stay put either.
This is also why sleep mode still uses a little battery: the computer powers down almost everything but keeps the RAM refreshed, so your open apps are still on the desk when you wake it. Hibernate goes one step further and copies the whole desk into storage, then switches off completely. That's why it survives a dead battery but takes longer to wake up.
Here's where it gets dramatic. Computer speeds are measured in nanoseconds (ns), billionths of a second, which is meaningless to a human brain. So let's stretch time. Pretend that one trip to RAM takes 1 second, and scale everything else by the same factor.
One more level appears in the list: CPU cache. It's a few small pockets of extra-fast memory built into the processor chip itself (labelled L1, L2 and L3, from smallest and fastest to biggest and slowest). In the office picture, it's the sheet of paper already in your hand. The CPU automatically keeps copies of recently used bits of RAM in there, because even the desk is "far" from the CPU's point of view.
How long does one fetch take?
These are rough, commonly quoted figures for the time to fetch one small piece of data. Exact numbers vary a lot between machines and generations, but the ratios are what matter, and they've held up for years: cache is roughly 10 to 100 times faster than RAM, RAM is roughly 1,000 times faster than an SSD, and an SSD is around 100 times faster than a spinning hard drive.
The hard drive is slow for a very physical reason: before it can read anything, an arm has to swing across the platter to the right track, then wait for the right spot to spin underneath it. At 7,200 revolutions per minute, one full turn takes about 8 milliseconds. No amount of clever electronics makes metal move faster.
Because of the trade-off in that pyramid. Per gigabyte, RAM costs many times more than SSD storage, and it would forget all your files every time you turned the computer off. Storage is cheap and permanent but far too slow for the CPU to work from directly. So computers use both, and spend a lot of effort shuffling data between the levels so that whatever the CPU needs next is usually already close by.
You can feel this shuffling when the desk fills up. If your open apps and browser tabs need more RAM than you have, the operating system (Windows, macOS, Linux, Android…) starts moving the least-used things from RAM out to a reserved area of storage, called swap or the page file, and bringing them back when needed. It works, but remember the table: storage is about a thousand times slower. That's the moment when switching between apps turns sluggish and everything feels like wading through mud. Closing a few tabs, or buying more RAM, clears space on the desk.
Every program you write lives in both places. The code file you save in your editor sits in storage. When you run it, the computer copies the program into RAM, and every variable (a named value your program keeps track of) lives in RAM while it runs. That has two consequences beginners bump into quickly:
Apps with "autosave" are simply doing the Save step for you every few seconds or minutes, so a power cut costs you only the last little bit.
You've edited a document for an hour without saving, with no autosave, when the power cuts out. What do you get back?
Your edits only existed in RAM, which is wiped when power stops. The copy in storage was untouched, so you get back exactly what it held: the last saved version.
When you open a game, what happens to the game's files in storage?
Loading is copying. The original stays in storage so it's there next time; the CPU works from the copy on the "desk".
If one RAM access took 1 second, roughly how long would one hard drive access take?
About 100 ns versus about 10 ms is a factor of roughly 100,000. 100,000 seconds is almost 28 hours. (About 17 minutes is the SSD.)
Why does a laptop in sleep mode still slowly drain its battery?
RAM must be refreshed constantly or it forgets, so sleep keeps it powered. The SSD keeps files without any power. Writing RAM to storage and switching off is what hibernate does.
Next time an app shows a loading bar, you'll know what it's doing: carrying files from the cabinet to the desk.