NelsonLabs

How Computers Think

Before writing code, it helps to understand what's actually happening inside a computer. You don't need to be an electrical engineer โ€” but knowing the basics will make everything else make more sense.

Computers only understand 0s and 1s

At the lowest level, a computer is made of billions of tiny switches. Each switch is either ON (1) or OFF (0). Everything โ€” every image, song, video, message, and program โ€” is stored as a long sequence of these 0s and 1s. This system is called binary.

ANALOGY

Real-world analogy: Light switches. Imagine a room full of light switches. Each switch is either on or off. By combining millions of switches in specific patterns, you can represent any number, letter, colour, or instruction. That's essentially what a computer processor does โ€” at billions of operations per second.

So how does Python or JavaScript work if computers only understand 0s and 1s?

This is where programming languages come in. When you write code in JavaScript or Python, a special program called a compiler or interpreter translates your human-readable instructions into the machine instructions the computer actually understands. You write English-like code โ†’ the computer converts it โ†’ the processor executes it.

โœ๏ธ
You write code
In a human-readable language like JavaScript, Python, or others.
๐Ÿ”„
It gets translated
A compiler or interpreter converts your code to machine instructions.
โšก
The CPU runs it
The processor executes the instructions at billions of operations per second.
๐Ÿ“บ
You see the result
The output appears on screen, in a file, or as a network response.

The key parts of a computer

PartWhat it doesReal-world equivalent
CPU (Processor)Executes instructions โ€” the brainA chef cooking the meal
RAM (Memory)Temporary workspace while runningThe kitchen counter โ€” active workspace
Storage (SSD/HDD)Long-term file storageThe fridge โ€” stores things permanently
GPUHandles graphics and heavy parallel tasksA team of assistants for visual work
OS (Operating System)Manages all programs and hardwareThe restaurant manager โ€” coordinates everything

What is a program, really?

A program is a file stored on your computer's storage. When you run it, the operating system loads it into RAM and the CPU starts executing the instructions one by one. When you close the program, it's removed from RAM. That's why RAM is called 'temporary' โ€” it only holds what's currently running.