A computer is a machine that processes binary data using electronic circuits, executing sequences of stored instructions (a program) by repeatedly fetching an instruction from memory, decoding it, and executing it — a cycle that transforms input into output entirely through the switching of transistors between on and off states.
A computer is a machine that follows instructions — and everything it does, from playing a video to running a nuclear simulation, comes down to billions of tiny switches turning on and off, billions of times per second.
It all starts with a switch
Inside every computer — your phone, your laptop, a supercomputer — there are billions of microscopic switches called transistors. Each transistor does exactly one thing: it is either on or off. That's it. There is no middle ground, no halfway, no maybe.
A transistor on = 1. A transistor off = 0. Two possible states. Two digits. This is why computers use binary — not because it's clever, but because physical switches only have two positions. The entire digital world is built on that single constraint.
A modern smartphone contains around 15 billion transistors etched onto a chip smaller than a fingernail. A high-end desktop CPU contains over 50 billion. These transistors switch states billions of times every second — and from that switching, everything else emerges.
Why 1s and 0s are enough for everything
It seems impossible that everything — every photograph, every song, every word in every document — could be represented using only 1s and 0s. But consider: the English language uses only 26 letters, yet those 26 symbols can express any idea a human mind can form. Two symbols can do the same thing, given enough of them.
A single binary digit (called a bit) can hold two values: 0 or 1. Eight bits together form a byte. A byte can represent 256 different values — enough for every letter in the English alphabet, every digit, and every punctuation mark. More bytes together represent larger numbers, longer text, colours, sounds, video frames, instructions — anything.
The letter 'A' is stored in memory as 01000001. The number 65 in a computer is also 01000001. What distinguishes them is not the bits themselves, but how the program chooses to interpret them. The computer only ever stores bits — it is the software that gives those bits meaning.
Transistors build logic
Connect a few transistors in the right arrangement and you get something new: a logic gate. A logic gate takes one or two bits as input and produces one bit as output based on a fixed rule.
An AND gate outputs 1 only when both of its inputs are 1. An OR gate outputs 1 if either input is 1. A NOT gate flips a single bit — turns a 1 into a 0 and vice versa. These three simple operations, combined in vast numbers, can perform any computation that is mathematically possible. This was proved by the mathematician George Boole in 1847, decades before electronic computers existed.
Connect enough logic gates and you can build a circuit that adds two numbers together. Connect more and you can build one that compares numbers, stores values, and makes decisions. Keep going and you have a processor — a machine that can, in principle, compute anything.
The CPU: the machine that follows instructions
The Central Processing Unit (CPU) is the part of the computer that does the actual work. It is a chip containing millions of logic gates arranged to perform arithmetic, compare values, move data from place to place, and make decisions.
But a CPU alone cannot do anything useful. It needs instructions — a list of specific operations to perform, in order. That list of instructions is a program. Programs are stored in memory.
A CPU is like a kitchen appliance that can do exactly what you tell it to — but only exactly what you tell it. A microwave doesn't "decide" to heat food. It follows a fixed sequence of steps the moment you press start. A CPU is the same, only faster: it executes billions of precisely specified steps per second, each one determined entirely by the program it was given.
Memory: where programs and data live
Memory (specifically RAM — Random Access Memory) is where the computer stores programs while they are running and the data those programs are working on. Memory is fast — the CPU can read from or write to it billions of times per second.
Memory is temporary. When you turn off your computer, everything in RAM disappears. For permanent storage — your files, your photos, your installed programs — computers use storage: hard drives, solid-state drives, or flash chips. Storage is slower than RAM but holds data when the power is off.
The loop that makes it all work
The CPU runs one loop, continuously, for as long as the computer is on. This loop has three steps:
1. Fetch. The CPU reads the next instruction from memory. It knows which instruction to fetch next because it keeps track of its position using a register called the program counter.
2. Decode. The instruction arrives as a binary number. The CPU decodes it — figures out what operation it represents. "Add these two numbers." "Store this value." "Jump to a different part of the program."
3. Execute. The CPU performs the operation. This might involve the Arithmetic Logic Unit (ALU), which handles addition, subtraction, and comparisons. Or it might involve reading from or writing to memory. When the operation is complete, the program counter advances and the cycle begins again.
This fetch-decode-execute cycle repeats billions of times per second. Every program ever written — from a simple calculator to the software that controls a spacecraft — is a sequence of these cycles happening one after another.
How software connects to all of this
You write code in a programming language like Python or Java. That code is human-readable. Computers cannot execute it directly. Before a program runs, it is translated into machine code — binary instructions the CPU understands. This translation is done by a compiler or interpreter.
Machine code for an Intel processor looks different from machine code for an ARM processor, which is why software written for one type of processor cannot run on another without translation. The instruction set — the vocabulary of operations a specific CPU understands — is specific to that processor's architecture.
Between the hardware and the software that users see sits the operating system — a program that manages the CPU, memory, storage, and all other hardware, presenting a clean interface that applications can use without knowing the details of the physical chips beneath them.
Transistors and the physical basis of computation
A transistor is a semiconductor device that functions as an electronic switch. In MOSFET technology — the type used in virtually all modern processors — applying a voltage to the gate terminal allows current to flow between the source and drain terminals. Removing the voltage stops the current. On = conducting. Off = not conducting.
Transistors in modern processors are fabricated at the nanometre scale. As of 2026, leading-edge manufacturing processes produce transistors with gate lengths below 3 nanometres. A single strand of human DNA is approximately 2.5 nanometres wide. These dimensions approach physical limits set by quantum mechanics — electrons begin to tunnel through barriers rather than being stopped by them, causing leakage current and heat.
Transistors are grouped on silicon wafers using photolithography — a process of exposing light-sensitive chemicals through a mask to etch circuit patterns. Billions of transistors are fabricated simultaneously on a single wafer, then cut into individual chips (dies). The yield — the fraction of dies that function correctly — is a primary driver of chip cost.
The von Neumann architecture
Nearly every computer in use today follows the von Neumann architecture, first described by John von Neumann in his 1945 report First Draft of a Report on the EDVAC. The architecture's defining characteristic is the stored-program concept: programs and data share the same memory space, and the CPU fetches both using the same mechanism.
The architecture consists of four components:
- Central Processing Unit — containing an Arithmetic Logic Unit (ALU), a Control Unit, and a set of registers (small, fast on-chip storage locations)
- Memory — a single address space containing both program instructions and data
- Input devices — keyboard, mouse, network card, camera
- Output devices — display, speakers, network card, storage
The von Neumann bottleneck is a well-documented limitation of this design: because instructions and data share the same bus (the communication pathway between CPU and memory), they must be fetched sequentially. This limits the maximum throughput of a von Neumann machine. Modern CPUs mitigate this with caches, prefetching, and pipelining — but the fundamental bottleneck remains inherent to the architecture.
Boolean algebra and logic gates
George Boole's 1854 work An Investigation of the Laws of Thought established that logical operations could be expressed algebraically. Claude Shannon's 1937 master's thesis A Symbolic Analysis of Relay and Switching Circuits demonstrated that Boolean algebra could describe electronic circuits — establishing the theoretical foundation for digital computing.
The three fundamental gates — AND, OR, NOT — are logically complete: any Boolean function can be expressed using only these three operations. In practice, NAND and NOR gates are used instead in physical circuits, because each is individually universal (any Boolean function can be expressed using only NAND gates, or only NOR gates) and NAND/NOR are more efficient to fabricate.
From these primitives, increasingly complex circuits are built:
- Half adder — adds two single bits, produces a sum and a carry
- Full adder — adds two bits plus a carry-in, produces a sum and carry-out
- Ripple-carry adder — chains full adders to add multi-bit numbers
- Multiplexer — selects one of several inputs based on a control signal
- Decoder — converts a binary code into one-of-n output signals
- Flip-flop — stores a single bit; the basis of all registers and memory
CPU architecture in detail
The CPU contains several functional units working together:
Registers are the fastest storage in a computer — small, directly accessible locations inside the CPU. A typical 64-bit CPU has 16 to 32 general-purpose registers. The program counter (PC) holds the memory address of the next instruction. The stack pointer (SP) points to the top of the call stack. Status registers hold condition flags (zero, carry, overflow) set by the previous operation.
The Arithmetic Logic Unit (ALU) performs integer arithmetic (add, subtract, multiply, divide) and bitwise logical operations (AND, OR, XOR, NOT, bit shifts). Most CPUs also contain a separate Floating Point Unit (FPU) for floating-point arithmetic, and SIMD units (Single Instruction, Multiple Data) for parallel operations on vectors of data — used heavily in graphics, signal processing, and machine learning.
The Control Unit decodes instructions and orchestrates the activities of all other CPU components — signalling the ALU which operation to perform, telling memory when to be read or written, and directing the result to the correct register.
The memory hierarchy
Memory in a computer system is organised as a hierarchy. Faster memory is more expensive and exists in smaller quantities closer to the CPU; slower memory is cheaper and larger. This hierarchy exists because of the fundamental tradeoff between speed, capacity, and cost in semiconductor design.
| Level | Type | Typical speed | Typical capacity | Purpose |
|---|---|---|---|---|
| L1 cache | SRAM, on-chip | ~1 ns | 32–128 KB per core | Most-recently used data and instructions |
| L2 cache | SRAM, on-chip | ~4 ns | 256 KB – 1 MB per core | Second-level cache |
| L3 cache | SRAM, on-chip | ~12 ns | 4–128 MB shared | Shared across cores |
| Main memory | DRAM (RAM) | ~60–100 ns | 4–256 GB | Running programs and data |
| SSD storage | Flash (NAND) | ~100 µs | 256 GB – 8 TB | Persistent storage |
| HDD storage | Magnetic disk | ~5–10 ms | 1–20 TB | Bulk persistent storage |
Cache operates on the principle of locality: programs tend to access the same data repeatedly (temporal locality) and tend to access data near data they just accessed (spatial locality). Caches exploit this by keeping recently and frequently used data close to the CPU. A cache hit — finding data in cache — avoids the slow round-trip to main memory. A cache miss forces the CPU to stall while memory is fetched.
The fetch-decode-execute cycle in detail
The fetch-decode-execute cycle is the fundamental operational unit of a von Neumann computer. Each iteration processes one instruction.
Fetch: The Control Unit reads the instruction stored at the memory address in the Program Counter. The instruction is loaded into the Instruction Register (IR). The Program Counter is incremented to point to the next instruction.
Decode: The Control Unit decodes the binary instruction. An instruction consists of an opcode — the operation to perform — and one or more operands — the data or addresses the operation acts upon. The opcode determines what circuit to activate; the operands specify where to get input data and where to put output.
Execute: The decoded instruction is executed. For arithmetic, the ALU performs the operation. For memory access (LOAD/STORE), the memory subsystem is engaged. For control flow (JUMP, BRANCH), the Program Counter is set to a new address rather than the default next address. The result is written to the destination register or memory location.
Modern CPUs do not execute one instruction at a time in strict sequence. Pipelining overlaps the stages of multiple instructions simultaneously — while one instruction is executing, the next is being decoded, and the one after that is being fetched. Superscalar execution runs multiple pipelines in parallel. Out-of-order execution reorders instructions to avoid stalls. Branch prediction speculatively executes instructions along the likely branch before the branch condition is known. These techniques allow modern CPUs to complete multiple instructions per clock cycle, per core.
From machine code to programming languages
Machine code is the binary encoding of instructions a specific CPU executes directly. Each processor family has an Instruction Set Architecture (ISA) — the specification of which operations the processor supports and how they are encoded in binary. The x86-64 ISA (used in most desktop and laptop CPUs) and the ARM ISA (used in most phones, tablets, and Apple Silicon Macs) are different and incompatible: a program compiled for one cannot run on the other without modification.
Assembly language is a human-readable representation of machine code — each instruction name corresponds directly to a machine code opcode. Writing in assembly requires knowing the register names, instruction names, and memory addressing modes of a specific ISA.
High-level languages (C, Python, Java, Rust, and all others) abstract away the ISA entirely. A compiler translates source code into machine code for a target ISA. An interpreter reads source code and executes it directly, generating machine operations on the fly. Languages like Java use a hybrid approach: a compiler produces bytecode for a virtual machine (JVM), and the JVM executes that bytecode — allowing the same compiled program to run on any architecture that has a JVM implementation.
The theoretical foundation: Turing's universal machine
Alan Turing's 1936 paper On Computable Numbers, with an Application to the Entscheidungsproblem (Proceedings of the London Mathematical Society, 1936, Series 2, vol. 42, pp. 230–265) introduced the abstract model now called the Turing machine. A Turing machine consists of an infinite tape divided into cells, each containing a symbol from a finite alphabet; a read/write head that moves along the tape; a finite set of states; and a transition function that, given the current state and the symbol under the head, specifies what symbol to write, which direction to move, and which state to enter next.
Turing proved that a single Universal Turing Machine (UTM) could simulate any other Turing machine given the other machine's description as input. This is the theoretical basis for general-purpose computing: a single machine, given the right program (description), can compute anything that any other machine can compute. The stored-program computer is a physical realisation of the UTM concept.
The Church-Turing thesis (independently proposed by Alonzo Church using lambda calculus and Turing using Turing machines, both in 1936) conjectures that any function computable by an effective method can be computed by a Turing machine. This thesis is not formally provable — it is a statement about the relationship between informal intuition and formal definition — but no counterexample has been found in 90 years of computation theory.
Von Neumann architecture: original specification
John von Neumann's First Draft of a Report on the EDVAC (June 30, 1945) formalized the architecture of the EDVAC (Electronic Discrete Variable Automatic Computer). The report defined five logical organs:
- CA — Central Arithmetical organ (the ALU)
- CC — Central Control organ (the Control Unit)
- M — Memory (a single address space for instructions and data)
- I — Input organs
- O — Output organs
The document is notable for introducing the stored-program concept explicitly: "the orders and the data that the machine has to process are both represented by the same kind of numerical data in a single storage medium." This contrasts with earlier fixed-program machines (ENIAC used physical rewiring to change programs) and with the Harvard architecture, which separates instruction and data memory onto distinct buses.
CMOS transistors and modern fabrication
Modern processors use Complementary Metal-Oxide-Semiconductor (CMOS) technology, which pairs n-type and p-type MOSFET transistors. CMOS circuits consume power only when switching states — not when holding a static value — giving them dramatically lower static power dissipation than earlier bipolar transistor technologies. This property was essential for the density scaling enabled by Moore's Law.
Moore's Law (Gordon Moore, "Cramming more components onto integrated circuits," Electronics, vol. 38, no. 8, April 1965) observed that the number of transistors per integrated circuit roughly doubled every 12 months (later revised to every 24 months). Moore's Law has held approximately true for six decades but is approaching physical limits: at sub-3nm nodes, quantum tunnelling causes significant leakage current, and the energy required to switch a gate approaches thermal noise. The industry is pursuing 3D stacking (chiplets, High Bandwidth Memory), Gate-All-Around (GAA) transistor designs, and new materials (III-V semiconductors, 2D materials) to continue scaling.
The x86-64 Instruction Set Architecture is specified in: Intel® 64 and IA-32 Architectures Software Developer's Manual, Intel Corporation (current edition at intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html). The ARM ISA is specified in: Arm Architecture Reference Manual for A-profile architecture, Arm Limited (current edition at developer.arm.com/documentation). These are the authoritative primary sources for instruction-level behaviour.
The fetch-decode-execute cycle: formal state transitions
The control unit of a CPU is implemented as a finite state machine. The fetch-decode-execute cycle defines the state transitions. In a simplified model with registers PC (Program Counter), IR (Instruction Register), MAR (Memory Address Register), and MDR (Memory Data Register):
-- FETCH
MAR ← PC -- load program counter into memory address register
MDR ← Memory[MAR] -- read instruction from memory into memory data register
IR ← MDR -- transfer instruction to instruction register
PC ← PC + 1 -- advance program counter to next instruction
-- DECODE
opcode ← IR[31:26] -- extract operation code (architecture-specific bit range)
operand1 ← IR[25:21] -- extract first operand
operand2 ← IR[20:16] -- extract second operand
dest ← IR[15:11] -- extract destination register
-- EXECUTE (varies by opcode)
if opcode == ADD:
Registers[dest] ← Registers[operand1] + Registers[operand2]
elif opcode == LOAD:
MAR ← Registers[operand1] + sign_extend(IR[15:0])
MDR ← Memory[MAR]
Registers[dest] ← MDR
elif opcode == BRANCH_IF_ZERO:
if Registers[operand1] == 0:
PC ← PC + sign_extend(IR[15:0]) -- relative branch
-- ... and so on for each opcode
Instruction Set Architectures: RISC versus CISC
The two dominant ISA design philosophies are CISC (Complex Instruction Set Computer) and RISC (Reduced Instruction Set Computer). The distinction was articulated by David Patterson and Carlo Séquin in their 1980 paper "RISC I: A Reduced Instruction Set VLSI Computer" (ACM SIGARCH Computer Architecture News, 1981).
- CISC (exemplified by x86): instructions can be complex, multi-step operations that directly perform what a programmer might write in a high-level language. Variable instruction length. Many addressing modes. Hardware microcode implements complex instructions. x86 has accumulated thousands of instructions across its history.
- RISC (exemplified by ARM, MIPS, RISC-V): instructions are simple, atomic operations that execute in a single clock cycle. Fixed instruction length. Load/store architecture (only LOAD and STORE access memory; all arithmetic operates on registers). More instructions required to express the same computation, but each executes faster and more predictably.
In practice, modern x86 CPUs translate CISC instructions into RISC-like micro-operations internally before execution. The architectural distinction between RISC and CISC has become less important at the hardware level — the interface presented to software remains, but the implementation below is often similar.
Key papers and textbooks
- Turing, A. M. (1936). "On Computable Numbers, with an Application to the Entscheidungsproblem." Proceedings of the London Mathematical Society, Series 2, 42, 230–265.
- von Neumann, J. (1945). First Draft of a Report on the EDVAC. Moore School of Electrical Engineering, University of Pennsylvania.
- Shannon, C. E. (1937). "A Symbolic Analysis of Relay and Switching Circuits." Master's thesis, Massachusetts Institute of Technology.
- Moore, G. E. (1965). "Cramming more components onto integrated circuits." Electronics, 38(8).
- Patterson, D. A. & Hennessy, J. L. (2020). Computer Organization and Design: The Hardware/Software Interface (ARM and RISC-V editions). 6th ed. Morgan Kaufmann.
- Tanenbaum, A. S. & Austin, T. (2012). Structured Computer Organization. 6th ed. Pearson.