What Makes a Computer Run
A plain-English guide to the CPU, RAM, and storage, and how they work together when you run a program.
What Makes a Computer Run
Before you learn how code runs, it helps to know what is inside a computer.
Any time you open a game, a browser, or a Python script, the hardware has to do three main jobs:
- do the thinking
- hold what is being used right now
- store things for later
Those jobs are handled by the CPU, RAM, and storage.
CPU. The brain
The CPU is the part that runs instructions.
If your code says result = 5 + 3, the CPU does the math.
If your program calls a function, the CPU moves to that part of the code and runs it.
Inside the CPU, a few things happen:
- one part reads instructions and decides what to do next
- one part does math and comparisons
- tiny storage spots hold small pieces of data while the CPU works
The CPU is fast. Really fast. But it has a catch.
It can only work with data that is already close by. That usually means data in RAM.
RAM. The workspace
RAM is where your computer keeps things it is using right now.
When you open a program, your computer loads it into RAM. Then the CPU reads the program from RAM while it runs.
A simple way to think about it:
- storage is your bookshelf
- RAM is your desk
You pull what you need off the shelf and put it on the desk so you can use it quickly.
RAM is fast, but it does not last. If you close a program, that space can be reused. If your computer shuts off, RAM gets wiped.
That is why unsaved work can disappear after a crash or power loss.
Storage. The long term memory
Storage is where files live when you are not using them.
This includes:
- your operating system
- apps and games
- photos and videos
- documents
There are two common types:
HDD (Hard Disk Drive)
HDDs use spinning disks and a moving arm. They are usually cheaper and can store a lot. But they are slower.
SSD (Solid State Drive)
SSDs use chips and have no moving parts. They are much faster than HDDs. They usually cost more per gigabyte.
Storage keeps data even when the computer is off. But it is slower than RAM.
How they work together
Here is what happens when you run a Python program:
- Your computer finds the program on storage.
- It loads the Python interpreter into RAM.
- It loads your script into RAM.
- The CPU reads instructions from RAM and runs them.
- Results are kept in RAM while the program is running.
- If you save something, it gets written back to storage.
So the flow is usually:
Storage → RAM → CPU → RAM → Storage
Why your computer sometimes slows down
These parts are not equally fast.
- CPU is the fastest, but it cannot hold much
- RAM is fast and holds a decent amount
- storage holds a lot, but it is slow
That is why programs take time to open, but feel faster after they load.
And it is also why running out of RAM hurts. When RAM is full, the computer starts using storage as backup memory. That works, but it is much slower. Everything can lag.
Why this matters for programming
This explains a few common things you will see as a programmer:
- big data structures take up RAM
- reading large files from storage takes time
- programs run faster once their data is in RAM
- memory-heavy code can slow down a whole system
If you remember one idea, make it this:
The CPU can only move fast when the data it needs is already in RAM.