How Computers and Software Actually Work (From Bits to Programs)
You use computers every day. You tap a screen and a message flies to a friend across the planet. You type a few words and a search engine returns ten million answers in half a second. You ask a chatbot a question and it writes you a paragraph. Most people treat all of this as magic — something that "just works," powered by forces they could never understand.
It is not magic. Every single thing a computer does can be traced back to a few simple ideas built on top of each other, layer by layer. This chapter takes you on a tour up that stack: from the tiniest building block (a single 0 or 1) all the way up to the programs, the internet, the cloud, and the AI that talk to you. You need no prior knowledge. By the end you will understand, in plain language, what is actually happening inside the device in your hand.
One idea will return again and again, so let us name it at the very start.
22.1 What a computer actually is
Strip away the screen and the apps, and a computer is one thing: a machine that follows a list of instructions to store, move, and transform information. That is it. It does not think. It does not understand. It does exactly what it is told, in order, very fast, and never gets bored or tired.
22.2 Bits and bytes: everything is light switches
How does a machine store a photo, a song, and your bank balance using nothing but electricity? The answer is the most fundamental idea in computing.
- Bit
- The smallest unit of information: a single 0 or 1, like one light switch that is either OFF or ON.
- Byte
- A group of 8 bits. Eight switches in a row.
With one switch you can say two things (off or on). With two switches you get four combinations (off-off, off-on, on-off, on-on). Each switch you add doubles the possibilities. By the time you have 8 switches — one byte — you have 256 different combinations. That is enough to give a unique pattern to every letter of the English alphabet (upper and lower), every digit, and every punctuation mark. This mapping of patterns to characters is called ASCII.
Numbers, text, images, video, sound — all of it, at the bottom, is patterns of 0s and 1s. This is called binary. The man who first defined the "bit" as the basic unit of information was Claude Shannon, whose 1940s work on information theory underpins the entire digital age.
22.3 The parts inside the box
A handful of physical parts do all the work. The cleanest way to understand them is with a kitchen.
The CPU — the cook
- CPU (Central Processing Unit)
- The "brain" chip that executes instructions, one tiny step at a time — but billions of times per second.
- Clock speed (measured in GHz) — how many steps per second. 3 GHz means roughly three billion tiny steps each second.
- Cores — modern chips have several cooks (cores) working in parallel, so they can do several things at once.
RAM — the counter
- RAM (memory)
- Fast, temporary workspace holding whatever the computer is using right now. Wiped clean the moment power goes off.
Storage — the pantry
- Storage (SSD or hard disk)
- Slower but permanent space that keeps your files even when the power is off.
Why your computer slows down with too many tabs
Computers stack memory from tiny-and-instant to huge-and-slow — this is the memory hierarchy: registers (in your hand) → cache → RAM (the counter) → SSD (the pantry) → the cloud (the store across town). The closer and faster, the smaller. When you open too many browser tabs, the counter (RAM) fills up. The computer is forced to start using slow storage as a backup workspace — called swapping — and everything crawls, because it is now running back and forth to the pantry for every little thing.
Finally, Input/Output (I/O) covers how the machine senses the world and shows results — keyboard, screen, network, sensors. These are the clerk's eyes, ears, and mouth.
This overall design — a CPU, memory, and a stored list of instructions — is called the Von Neumann architecture, after John von Neumann. Nearly every computer ever built still follows it.
THE KITCHEN MODEL OF A COMPUTER
CPU (the cook) <-- does the work, fast & literal
|
RAM (the counter) <-- fast, temporary, small
| holds what's in use NOW
SSD (the pantry) <-- slow, permanent, big
keeps files when power is off
"Save" = move from counter ---> pantry
22.4 Software: the sheet music
The parts above are hardware — the physical body. But a body does nothing without instructions. Those instructions are software.
Writing the instructions: programming
Programming means writing precise instructions in a language a human can read, which is then translated into the 0s and 1s the machine runs.
- Programming language
- A structured vocabulary and grammar for giving instructions — Python, JavaScript, and many others. You pick one based on the job, the way you might pick a spoken language based on where you are.
The human-readable instructions are called source code. But the CPU only understands binary. Two approaches bridge that gap:
| Approach | What it does | Analogy |
|---|---|---|
| Compiler | Translates the whole program into machine code ahead of time, then runs it. | Translating an entire book before anyone reads it. |
| Interpreter | Translates and runs the program line by line, as it goes. | A live interpreter translating your speech sentence by sentence. |
The four building blocks of all programs
Astonishingly, almost every program ever written is built from just four ideas, together called control flow:
- Variable
- A named container that stores a value. Like a labeled jar: a jar labeled
priceholding the number 50. - Conditional (if/else)
- Making a decision. "If it's raining, take an umbrella, else wear sunglasses."
- Loop
- Repeating steps. "Stir 10 times." The computer's true superpower: it will do this a billion times without complaint.
- Function
- A named, reusable block of steps. Define "make-the-sauce" once, then call it whenever you need it, instead of rewriting the steps each time.
Bugs and debugging
- Bug
- A mistake in the instructions that causes wrong behavior.
- Debugging
- Finding and fixing that mistake.
22.5 Algorithms and data structures: recipes and organization
Two ideas decide whether a program is fast or painfully slow.
- Algorithm
- A step-by-step procedure to solve a problem. A recipe. Directions to a friend's house.
- Data structure
- A way of organizing data so it can be used efficiently.
The crucial insight: the same goal can be reached by different algorithms with wildly different speeds. Finding a word in a dictionary by flipping every page one at a time works — but it is painfully slow. Jumping to roughly the right letter and narrowing down is the same task done smartly.
Common data structures, by kitchen analogy:
- List / array — a numbered shelf; items in order, fetched by position.
- Dictionary / hash map — labeled mailboxes; instant lookup by name. Ask for "Smith" and go straight to that box.
- Stack — a pile of plates; last one placed is the first one taken (LIFO).
- Queue — a checkout line; first to arrive is first served (FIFO).
- Tree — an org chart or family tree; branching hierarchy.
- Graph — a map of cities and roads, or a social network of who knows whom.
Big-O: how things scale
- Big-O notation
- A way to describe how an algorithm's time or memory grows as the amount of data grows.
The beginner takeaway is not "how fast on my laptop today" but "how does this behave when the data gets 1,000 times bigger?" An approach that is fine for 100 customers can melt down at 100 million. Donald Knuth, who literally wrote the book on algorithm analysis, also gave the field its most famous warning: "premature optimization is the root of all evil" — don't make code clever before you know it needs to be.
22.6 The operating system: the building manager
You never write machine instructions to talk to your screen or hard drive directly. A master program does that for you and every other app.
- Operating system (OS)
- The master program that manages the hardware and lets other programs run. Windows, macOS, Linux, Android, iOS.
- Process
- A running program.
- Multitasking
- The OS switching between many processes so fast they appear to run at the same time — like one chef tending several pots so quickly every dish seems watched at once.
- File system
- How the OS names, organizes, and locates stored data — a filing cabinet with labeled drawers and folders.
- Driver
- A small program letting the OS talk to one specific piece of hardware, like a printer or graphics card. A translator hired to speak to one particular supplier.
22.7 How the internet works
Now we connect machines together. This is where the most useful single mental model in the whole chapter lives.
- Network
- Computers connected to share data.
- The internet
- The global "network of networks" — every local network linked together.
The client–server model
- Client
- The device asking for something — your phone, your browser.
- Server
- An always-on computer that provides things when asked.
Finding the right computer: IP addresses and DNS
- IP address
- A unique numeric address identifying a device on a network — a postal address for a computer (e.g.,
142.250.1.1). The older format is IPv4; because the world ran out of those, a much larger format called IPv6 now exists too. - DNS (Domain Name System)
- The service that translates human names like
google.cominto the numeric IP address the network actually uses.
google.com; DNS looks up the number.Packets and routing
- Packet
- A small, labeled chunk of data. Big data is chopped into many packets that travel independently and are reassembled at the destination.
The rules: TCP/IP, HTTP, HTTPS
- TCP/IP
- The core rule set under the internet. IP handles addressing and routing packets. TCP guarantees they all arrive, in order, none missing — resending any that get lost.
- HTTP / HTTPS
- The language browsers and web servers use to exchange pages and data. HTTPS is the encrypted version — the padlock in your address bar.
Vint Cerf and Bob Kahn designed TCP/IP and are called "fathers of the internet." Tim Berners-Lee invented the World Wide Web — HTTP, HTML, and web addresses — at CERN in 1989.
The full request lifecycle — the capstone
Here is what actually happens, start to finish, every time you visit a website. Memorize this flow; it explains nearly everything online.
WHAT HAPPENS WHEN YOU OPEN A WEBSITE 1. You type google.com and press Enter 2. DNS lookup: "what is google.com's IP address?" 3. TCP connection opens (a quick 3-step handshake) 4. HTTPS sets up encryption (the padlock) 5. Browser sends an HTTP request: "send me the page" 6. Server responds with HTML, CSS, JavaScript 7. Browser assembles and draws the page on screen
22.8 Data: databases and APIs
Websites need to remember things — your orders, your login, your messages. That memory lives in databases, and programs share it through APIs.
- Database
- An organized system for storing, retrieving, and updating large amounts of data reliably.
| Type | How it stores data | Analogy |
|---|---|---|
| SQL (relational) | Linked tables with fixed rows and columns, strict structure. | A strict accounting ledger with fixed columns. |
| NoSQL | Flexible documents or key-value pairs; each record can differ. | A box of index cards where each card can hold different fields. |
The relational (SQL) model was invented by Edgar F. Codd. A query is a request to a database — like asking a librarian, "give me every book by this author published after 2020."
APIs: the menu
- API (Application Programming Interface)
- A defined way for one program to request services or data from another.
{"name": "Sam", "price": 50} that both sides agree to use.22.9 The cloud
- The cloud
- Renting computing power, storage, and software over the internet instead of owning the hardware yourself.
A few key ideas make the cloud work:
- Virtual machine (virtualization)
- Software that splits one physical computer into several independent "virtual" computers. Like dividing one big warehouse into separately-locked rented units.
- Container (e.g., Docker)
- A package that bundles an app with everything it needs to run identically anywhere. Like a standardized shipping container that runs the same on any ship or truck.
- Orchestration (e.g., Kubernetes)
- Software that manages thousands of containers automatically — the port crane system coordinating all those containers.
IaaS, PaaS, SaaS — the pizza model
Cloud services come in tiers based on how much the provider manages for you. The classic teaching device is "pizza as a service":
| Tier | You manage | Pizza analogy | Example |
|---|---|---|---|
| IaaS (Infrastructure) | The operating system and apps; they give you raw servers. | They give you the kitchen; you make the pizza. | Amazon EC2 |
| PaaS (Platform) | Just your app; they handle the platform underneath. | Kitchen, dough, and oven ready; you add toppings. | Heroku, Google App Engine |
| SaaS (Software) | Nothing technical; you just use the finished app. | Pizza delivered; you just eat. | Gmail, Salesforce |
- Serverless (Functions-as-a-Service)
- You upload code that runs only when triggered; the provider handles all servers and scaling, and you pay per execution — nothing when idle. Like a motion-sensor light: off and costing nothing until someone walks in, then instantly on.
- Scalability & load balancing
- Handling more users by adding capacity. A load balancer spreads incoming traffic across many servers — like opening more checkout lanes at rush hour with a greeter directing shoppers to the shortest line. Adding a bigger machine is vertical scaling; adding more machines is horizontal scaling.
22.10 Cybersecurity basics
All of this stores your money, identity, and private life. Protecting it rests on a few durable ideas.
- The CIA triad
- Security's three goals: Confidentiality (only the right people can see it), Integrity (it isn't tampered with), Availability (it's there when needed). Like a bank vault: secret contents, untampered records, open during business hours.
- Encryption
- Scrambling data so only someone with the key can read it. A locked diary. Data is encrypted both "at rest" (while stored) and "in transit" (while traveling — that's the HTTPS padlock).
- Authentication vs authorization
- Authentication = proving who you are (showing ID at the door). Authorization = what you're allowed to do once inside (your ticket only opens certain rooms).
- MFA (multi-factor authentication)
- Requiring two or more proofs of identity — a password plus a code on your phone. Like an ATM needing both your card (something you have) and your PIN (something you know). It is the single most effective defense against a stolen password.
- Phishing & social engineering
- Tricking a person — not the machine — into giving up secrets or access. A con artist posing as your bank to get your PIN.
- Malware
- Malicious software — viruses, spyware, and ransomware (a digital burglar who changes your locks and demands payment for the key).
- Zero Trust
- A modern model that trusts no one by default and verifies every request, even from inside the network — an office where every door needs a badge swipe every time, with no "you're inside so you must belong" assumption.
22.11 AI and machine learning
Now the layer everyone is talking about. The first thing to fix is the vocabulary, because the words are used loosely.
THE NESTING DOLLS OF AI +-------------------------------------------+ | AI (machines doing "smart" tasks) | | +-------------------------------------+ | | | Machine Learning | | | | (learns patterns from data) | | | | +-------------------------------+ | | | | | Deep Learning | | | | | | (many-layered neural nets) | | | | | | +-----------------------+ | | | | | | | Transformers / LLMs | | | | | | | +-----------------------+ | | | | | +-------------------------------+ | | | +-------------------------------------+ | +-------------------------------------------+
- AI (Artificial Intelligence)
- The broadest term: machines doing tasks that seem to need intelligence.
- Machine Learning (ML)
- A subset where machines learn patterns from data instead of being given explicit rules.
- Deep Learning
- ML using many-layered neural networks.
Most of what people call "AI" today is really machine learning. Here is the deep idea that makes it different from ordinary programming:
| Traditional programming | Machine learning |
|---|---|
| You write the rules. Feed in data. Get answers. | You feed in data and answers. The machine figures out the rules itself. |
- Training data, features, model
- The examples it learns from (training data), the relevant attributes it pays attention to (features), and the learned pattern-machine that results (the model). Like studying past exams, noticing which topics matter, and becoming good at the subject.
- Three styles of learning
- Supervised — learn from labeled examples (flashcards with answers). Unsupervised — find hidden groupings in unlabeled data (sorting a pile of photos nobody named). Reinforcement — learn by trial and error with rewards (training a dog with treats).
Neural networks
- Neural network
- A model loosely inspired by brain cells: layers of simple units that each pass a weighted signal forward, together learning complex patterns.
- Weights
- The "trust levels" the network assigns to each input — the numbers that get tuned during training.
The "godfathers of deep learning" — Geoffrey Hinton, Yann LeCun, and Yoshua Bengio — won computing's top prize for reviving these ideas.
Generative AI and Large Language Models
- Generative AI
- AI that creates new content — text, images, code, audio — rather than just sorting or labeling. The difference between a critic (labels things) and an author (makes new things).
- Token
- A small chunk of text. Language models break writing into tokens (roughly word-pieces).
- Embedding
- Each token turned into a list of numbers that captures its meaning, so words with similar meanings sit near each other in a kind of "meaning-space" — a giant map where "king," "queen," and "monarch" are neighbors while "banana" is far away.
- LLM (Large Language Model)
- A very large neural network trained on huge amounts of text to predict the next token. ChatGPT, Claude, and Gemini are LLMs.
- Transformer
- The neural-network design behind every modern LLM, introduced in the 2017 paper "Attention Is All You Need" (Vaswani et al., at Google).
- Attention
- The mechanism that lets the model weigh how relevant every other word is to each word, all in parallel, so it can track meaning across long passages.
Working with LLMs in practice
- Prompt
- Your instruction to the model.
- Context window
- How much text the model can consider at once — its short-term memory.
- Hallucination
- A confident but false output. The model fills in plausible-sounding text even when it doesn't actually know.
- Fine-tuning
- Further training a base model to specialize it for a specific task.
- RAG (retrieval-augmented generation)
- Feeding the model relevant documents at question time so it answers from real facts, not just its memory. An open-book exam where you hand the student the right reference pages before they answer.
22.12 How modern software gets built and shipped
Finally, the topmost layer: how all of this gets made and put in front of real users. Even if you never code, this is the shared language of every software team.
- Software development lifecycle / Agile
- The repeating cycle of plan → build → test → ship → learn, done in small, frequent increments. Like renovating a house room by room and getting feedback, rather than designing a whole mansion before laying a single brick.
- Version control (Git)
- A system that tracks every change to code and lets many people collaborate without overwriting each other. Like a souped-up "version history" in a shared document. A saved snapshot is a commit; a parallel copy for experimenting is a branch; combining branches is a merge; GitHub hosts it all online.
- Testing
- Automated checks that confirm code does what it should and keeps working as it changes. Like a smoke detector you install once that keeps watching — versus sniffing for smoke yourself every time.
- CI/CD
- Continuous Integration / Continuous Deployment: automation that tests every change and ships it to users automatically when it passes. A factory conveyor belt with quality-control gates — defects stopped, good work rolled straight out the door.
- Frontend / backend / full-stack
- Frontend = what the user sees and clicks (the dining room). Backend = the server logic and database behind it (the kitchen). Full-stack = both.
- Deployment & DevOps
- Getting software running on real servers for real users, plus the culture and tooling that keep building and operating smooth. Opening night, plus the stage crew keeping every show running.
- Monitoring & observability
- Watching a running system's health and getting alerted when something breaks — the dashboard warning lights and gauges of a car.
22.13 The threads that tie it all together
You have now climbed the whole stack — from a single switched 0 or 1, up through the CPU, software, the internet, the cloud, and AI, to the pipeline that ships it all. A few ideas ran through every floor:
- Abstraction is the spine. Each layer hides the messy one below and offers a simpler handle. That is what lets humans build things too complex for any one person to hold in their head.
- The request lifecycle is the heartbeat of the internet. DNS → TCP → HTTPS → HTTP → render. Every message, payment, map, and search is that loop running invisibly, billions of times a second.
- Computers are fast, literal, and dumb; AI is fluent but not truthful by design. Both are tools. Respect what they actually do, not what they appear to do.
- The human is the most-attacked part. Your habits — strong unique passwords, MFA, skepticism, prompt updates — protect you more than any single piece of software.