How Computers Work
Before coding, let's understand the machine we're going to command.
Basic Components
Processor (CPU)
The computer's "brain". Executes calculations and instructions.
Think of it as a super-fast chef: it can only do one thing at a time, but does it so quickly it seems simultaneous.
Memory (RAM)
Temporary memory. Stores what the computer is using right now.
It's like your work desk: the more space, the more things you can have open. But when you turn off the computer, everything is erased.
Storage (HD/SSD)
Permanent memory. Stores your files, programs, photos.
It's like a filing cabinet: slower to access, but nothing is lost when you turn off.
Simple Example
When you open a browser:
- Storage → The browser is saved here
- RAM → The browser loads into memory
- CPU → Executes browser instructions
Binary: The Computer's Language
Computers only understand binary: 0 and 1.
Hello → 01001000 01100101 01101100 01101100 01101111
Each 0 or 1 is a bit. 8 bits = 1 byte.
| Unit | Equivalent |
|---|---|
| 1 KB | 1,024 bytes |
| 1 MB | 1,024 KB |
| 1 GB | 1,024 MB |
| 1 TB | 1,024 GB |
Where Does Code Fit In?
When you write code in JavaScript:
alert("Hello!");It goes through this process:
Your code (JS) → Interpreter → Machine code (0s and 1s) → CPU executes
That's why we have programming languages: they're more readable for humans and are translated to binary.
Input, Processing and Output
Every program follows this cycle:
- Input - Receives data (keyboard, mouse, file)
- Processing - Does something with this data
- Output - Shows the result (screen, file, sound)
Example: calculator
- Input: numbers 2 and 3
- Processing: 2 + 3
- Output: shows 5
Operating System
The operating system (Windows, macOS, Linux) is the "manager" that:
- Controls hardware
- Allows programs to run
- Manages files
- Provides security
Think of it as the building's superintendent: it doesn't live in the apartments (programs), but keeps everything running.
Summary
- CPU: processes instructions
- RAM: temporary memory (fast)
- Storage: permanent memory
- Computers only understand binary (0 and 1)
- Programming languages are translated to machine code
- Everything follows: Input → Processing → Output
In the next lesson, we'll explore tech careers! 🚀