Facebook Pixel

Computer Components

What Makes a Computer Run

Before you can understand how programs execute, you need to know what's inside your computer. Every time you run a program—whether it's a Python script, a game, or a web browser—your computer's hardware works together to make it happen. Three main components play critical roles: the CPU, RAM, and storage.

The Three Key Components

Computer Architecture

CPU: The Brain

The Central Processing Unit (CPU) is your computer's brain. It executes instructions—the individual steps that make up your program. When your code says result = 5 + 3, the CPU performs that addition. When you call a function, the CPU jumps to that code and executes it.

Inside, the CPU has three main parts working together. The Control Unit fetches instructions from memory and figures out what each instruction means. The ALU (Arithmetic Logic Unit) does the actual calculations—addition happens through electrical circuits that flip bits on and off based on logic gates. Non-numerical operations like comparisons (10 > 7) also use these circuits: they subtract the numbers and check if the result is negative. The Registers are tiny storage spots (just a few bytes each) that hold numbers while they're being processed. When you add 5 + 3, the CPU loads both numbers into registers, the ALU performs addition through its circuits, and the result goes into another register.

The CPU operates incredibly fast, executing billions of instructions per second. A modern processor might run at 3 GHz (gigahertz), meaning it can perform 3 billion operations every second. This speed is why computers can handle complex tasks like rendering graphics, playing videos, or running your code in what feels like an instant.

But the CPU has one limitation: it can only work with data that's nearby. It needs instructions and data to be readily available in memory.

How CPU Works

RAM: The Workspace

Random Access Memory (RAM) serves as your computer's workspace. When you run a program, the operating system loads that program from disk into RAM. The CPU then fetches instructions and data from RAM billions of times per second.

Think of RAM as your desk while studying. You pull books (programs) from your bookshelf (disk) onto your desk (RAM) so you can reference them quickly. If a book isn't on your desk, you have to get up and grab it from the shelf—much slower than just looking down.

RAM is fast but temporary. Close a program and that data disappears from RAM. Turn off your computer and RAM completely clears. This is why unsaved work vanishes when your computer crashes—RAM loses everything without power.

Modern computers typically have 8-32 GB of RAM. A running program might use anywhere from a few megabytes to several gigabytes depending on what it does.

How RAM Works

Storage: Permanent Data

Your computer needs a place to store files permanently—documents, photos, programs, the operating system itself. Unlike RAM, storage persists when you turn off your computer. Two main types exist: Hard Disk Drives (HDD) and Solid State Drives (SSD).

Hard Disk Drives (HDD) use spinning magnetic platters. A mechanical arm moves across the disk to read and write data. HDDs are cheaper and offer large capacity (1-4 TB common), but the mechanical movement makes them the slowest storage option.

Hard Disk Drive

Solid State Drives (SSD) use NAND flash memory chips—similar to RAM chips but with different technology. SSDs have no moving parts, making them faster than HDDs. They're more expensive per gigabyte but have become standard in modern computers because the speed improvement is dramatic.

Solid State Drive

Both types are much slower than RAM. Even SSDs, despite using chips like RAM, use NAND flash technology designed to retain data without power—a different trade-off than RAM's DRAM technology optimized purely for speed.

When you double-click a program icon, the operating system copies that program from storage into RAM. Once loaded, the CPU can execute it. When you save a file, data moves from RAM back to storage for permanent keeping.

How They Work Together

Here's what happens when you run a Python program:

The operating system finds your Python script on disk. It loads the Python interpreter into RAM. The interpreter reads your script (also loaded into RAM) and begins executing it. The CPU fetches instructions from RAM, executes them, and stores results back in RAM. If your program saves data, that data moves from RAM to disk.

This three-tier system exists because of trade-offs. The CPU needs speed but can't store much data. RAM provides fast access to reasonably large amounts of data but loses everything when power cuts. Disk stores massive amounts permanently but operates slowly.

The Speed Hierarchy

These components form a hierarchy based on speed and size. The CPU is fastest but holds almost no data. RAM is fast and holds a moderate amount. Disk is slow but holds vast amounts.

Memory Hierarchy

This hierarchy explains why your computer behaves the way it does. Programs load slowly from disk (you see a loading spinner) but run quickly once in RAM. If you run out of RAM, your computer slows dramatically because the operating system starts using disk as backup RAM—orders of magnitude slower.

Running a Program Step by Step

Program Loading Process

Why This Matters for Programming

Understanding these components explains several programming realities:

Memory matters. When your program uses too much RAM, the computer slows down dramatically. The operating system starts using disk space as fake RAM (called "swap" or "virtual memory"), and since disk is much slower, everything grinds to a halt.

Data structures live in RAM. When you create a list or array, that data structure occupies RAM. Understanding how data structures organize in memory helps you understand their performance characteristics.

Loading takes time. Reading large files from disk is slow. This is why programs that process big datasets spend much of their time waiting for disk reads. Smart programs load data into RAM once and work with it there.

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro