The Computer Course #2: Guts and Brains

For a brief introduction to this blog series, start here.


There are two major components to the “stuff” that makes up a computer: any computer, from a 1960s warehouse-sized mainframe, to a Commodore 64 from the 1980s, to the iMac in your school’s computer lab, even to the iPad you read books (or watch YouTube videos) on at night and the iPhone I carry in my pocket.

Those two major components are the hardware — the physical object and the parts inside it — and the software — the sets of instructions that make the hardware do something instead of just sit there on the desk looking expensive.

Today we’ll be taking a high-level, conceptual look at what makes up both the hardware and software of a typical computer system. We’re not looking at specific brands of computers or programming languages, but we’ll be talking about the basic building blocks of hardware and software that just about every type of computer or computer-like device consists of.

Hardware

What’s inside a computer? What is “the computer”? Many times all of the “insides” of the computer are attached directly to the display — the screen — such as with an iMac or a mobile device like a tablet or smartphone. For laptop computers, the “insides” are mostly under the keyboard. And for a lot of desktop computers, there’s a separate box that either sits on the desk or on the floor that contains all of these important components.

A lot of today’s computers and “computing devices” cannot be opened, or at least should not be opened, because there are no “user serviceable parts” inside. That just means there’s nothing you can really do to fix or upgrade what’s inside, and trying to open up the case just might void your warranty if you break something.

But some computers, especially those desktop units, are designed to be upgraded by the user. Remove a few screws, and you can see all of the “stuff” inside that makes the computer work. The first thing you’ll notice inside any computer is the motherboard a fairly large, thin green board that everything else is attached to. But the motherboard by itself is pretty useless — it’s those things attached to it that actually make the computer work. The motherboard just provides a place for them all to live, and connections that let the components interact. Let’s look at some of those components.

CPU (Central Processing Unit, or Processor)

The CPU is the “brain” of a computer. These days, the CPU is a small, square chip, generally about an inch on a side, that is attached to the motherboard. Often the very small CPU will be covered by a much larger “heat sink” — a piece of heat-conducting metal, which itself is connected to a fan. The CPU gets really busy while the computer is running, and all of the electricity flowing around inside it can generate a tremendous amount of heat.

Heat is bad. At least for CPUs.

By using a heat sink and fan, the CPU can be kept cool, so it can keep doing it’s job, which is making everything inside the computer happen!

Remember last time when we started by talking about binary switches? A CPU is full of them. Billions of little electronic switches all stored inside a tiny chip.

The CPU has an instruction set — in short, the things it can do. The CPU cycles through its set of instructions millions of times per second, turning all of those little switches on and off by adding or removing an electrical charge to each of them. The instructions it uses to determine what to do are handled by the software, which we’ll get to a bit later.

Boot ROM (Read-only Memory) or Firmware

When you first turn on the computer, what happens? Well, if not for the boot ROM (or firmware), nothing would happen. On older computers the boot ROM was a special piece of software permanently written on a chip that was attached to the motherboard. These days the boot ROM process is usually handled by firmware — not quite hardware, not quite software. It’s a program, so it’s software, but it’s semi-permanently stored in a chip on the motherboard. (I say semi-permanently, because it can be updated, unlike a traditional ROM chip.)

The boot ROM contains a very limited set of software that tells the computer how to get things going when it is first turned on, then it hands off those duties to the operating system.

But we’re getting ahead of ourselves. Let’s keep going with the different pieces of hardware.

RAM (Random Access Memory, or simply Memory)

RAM, the memory, is another chip. In most computers, RAM is not permanently soldered onto the motherboard, but instead plugs into a special socket on the motherboard. This makes it really easy for the user to replace old RAM chips with newer ones that can store more data. (A big reason for this is that as technology advances, RAM often gets cheaper much more quickly than the rest of the components in a computer. Being able to upgrade your RAM allows you to keep the same computer longer, but make it more powerful and able to handle newer software!)

A RAM card may look a lot like a smaller version of the motherboard with its own set of chips soldered on, but the RAM chips work a lot differently than the CPU. RAM is used by the CPU as it runs software to store information it’s working with — your file data and even the programs themselves as they run — because RAM is really fast. The CPU assigns a memory address to each piece of data it’s using so it knows where to find it in the RAM.

GPU (Graphics Processing Unit, or Video Card)

Not all computers have a separate GPU; sometimes graphics processing is handled by the CPU. However for computers or devices (like video game consoles) where high-quality graphics and video are important, a dedicated GPU can make a huge difference.

Creating graphics to display on your screen is one of the most complicated things a computer has to do. There is a lot of very complex math involved in drawing on-screen objects, adding light and shading effects, creating smooth motion, etc. Most of this math involves floating point calculations. It’s not important to know a lot about floating point calculations here; basically, it just means working with numbers with a decimal point and an uncertain number of digits. This kind of math can be hard for humans, but it’s especially difficult for computers, since they really like integers (and two integers in particular: 0 and 1)!

By letting the GPU take care of all of that complicated math, the CPU can focus on its general-purpose tasks that make the computer run smoothly.

Networking: Ethernet, WiFi, etc.

In the early days of personal computers, each computer was like an island unto itself: most people’s computers were rarely connected to networks that allowed them to talk to other computers. These days, so much of what we do on computers involves the Internet that we can hardly imagine a non-networked computer.

The two main ways computers connect to networks are by a wire, called an Ethernet connection, or wirelessly, better known as WiFi. In general, Ethernet is faster and more reliable than WiFi, except for one big nuisance: that wire. A device that connects to the network wirelessly is a lot more mobile, so WiFi has become a lot more popular over the past ten years or so.

Storage (Hard Drives and Removable Media)

A computer can do a lot of amazing things while it’s running. But what happens when you turn it off? Well, without something to store data on — something that will keep that data even when the power is off — you’d have to start from scratch every time you turned on the computer: reinstalling all of your software, rewriting all of your files. It wouldn’t be very useful at all!

Computer storage capacity has grown immensely even as the size of storage devices has gotten smaller. There are two basic types of storage: hard drives, and removable media. Early personal computers didn’t have hard drives, and when they did, they were extremely expensive. A hard drive that could only hold 10 MB of data could cost thousands of dollars! (Such a small amount of storage would be completely useless with the requirements of today’s computers and devices.)

By the mid-1980s, most computers came with a hard drive of around 100 MB and also had removable storage in the form of floppy disks that stored 1.44 MB on a small magnetic plate inside a square-ish plastic case 3 1/2 inches long. These days you can easily get a Micro SD card that’s smaller than your fingernail and can store 64 GB of data. That’s as much as over 45 thousand floppy disks.

Early hard drives were like more complicated versions of a floppy disk, with several spinning platters coated in a magnetic substance that could remember all of the ones and zeroes the computer stored data in, even without any power. But these hard drives had a lot of moving parts and could fail. Most computers today still have a hard drive like this, but it’s becoming more and more common to replace them with SSD drives (Solid-State Drive). An SSD fits in the same connection on the motherboard as a regular hard drive, and does the same job for the computer — remembering its data when the power is turned off — but an SSD drive looks a lot more like RAM, and it has no moving parts. Like RAM, it’s also a lot faster than a traditional hard drive, which can have a huge effect on how fast a computer running from an SSD card feels, even if its other components are the same as a computer with a traditional hard drive.

Input Devices: Keyboard, Mouse, Trackpad, Touchscreen

So, your computer has all of these parts that can do incredible things. But how do you interact with it, tell it what to do? That’s where input devices come in. There are four main types of input device on modern computers and computing devices: a keyboard that lets you type words, a mouse or trackpad that controls the cursor moving around on the screen and lets you click to open, close or move windows, and these days often a touchscreen that combines elements of both a keyboard and a mouse while letting you interact directly with objects on the screen with your fingers.

Most input devices are either built directly into the outer casing of the computer (as with a laptop), or are attached by a USB cable or wirelessly using Bluetooth.

Display/Monitor

How do you see what the computer is doing? In the early days of mainframe computers, the computer would actually have a long strip of paper tape that it would print on. But printing words onto strips of paper is not a very effective way of interacting with a computer, and before long screens took over as the way a user can see what the computer is doing.

Displays have gotten much more powerful over time just like other parts of the computer. Today’s displays can show millions of colors and incredible detail, but as recently as the 1980s many monitors were limited to displaying text, generally in a grid 80 characters wide by 25 characters tall. A vestige of that 80×25 grid lives on today… any time you open the Terminal app on a Mac.

Peripherals

Any device that’s not inside the computer’s case, but connects to it via a wire like USB or wirelessly over WiFi or Bluetooth is called a peripheral. Monitors, keyboards and mice are peripherals, but peripherals also include other things like external hard drives, Internet routers, and printers.

Software

All of the hardware we’ve talked about so far, even the fancy CPU with its “instruction set”, can’t do anything without software. Software programs are ways of combining the CPU’s instruction set — the things it can do — into specific tasks. Think of the instruction set as ingredients. Software is the recipe for combining those ingredients into something delicious… or at least useful.

BIOS or EFI

The very most basic software a computer needs to run is store in the BIOS (Basic Input/Output System) ROM or EFI (Extensible Firmware Interface). This also generally includes a piece of software called the boot loader and it serves one purpose: it tells the computer how to start up. As soon as the computer is powered on, the BIOS fires up, performs some basic tests to make sure everything is working, and then runs the boot loader to tell the CPU where it can find the operating system. Once the CPU takes over and begins loading the operating system, the boot loader’s job is done.

Operating System (OS)

The operating system is the core of the computer. It contains the basic software that allows the CPU to combine its instruction set into groups of useful tasks and lets the different parts of the computer talk to each other to get things done.

The Kernel

The kernel is the heart of the operating system. It handles the most basic tasks of running the CPU.

Device Drivers

Every component of the computer — both internal parts like networking and the hard drive, and external peripherals like the mouse, monitor or printer — has a device driver that gets loaded on top of the kernel and tells the operating system how to make the component work. The operating system generally takes care of this low-level interaction between the components in a way that allows the higher level software not to worry about the specific details. That’s handled through what is often called the hardware abstraction layer.

Hardware Abstraction Layer

On top of the kernel and drivers lives the hardware abstraction layer. It is a part of the operating system that takes all of the specific details about how that computer’s components work — the specific brand and size of hard drive or network interface, for instance — and fits them into a generalized set of rules about how those types of components work. This way, the software that users interact with — or that most programmers write — doesn’t need to include instructions for every possible kind of hard drive or network interface.

Programming Language Interpreters

The instruction set a CPU understands is, generally speaking, not something most humans would understand — even experienced programmers. So programmers almost never write their software directly in machine language, and most modern operating systems wouldn’t even allow that, what with the hardware abstraction layer. So programmers use a variety of languages that are (somewhat) easier for humans to understand, like C++ or Java.

The problem is, with these languages the opposite problem exists: humans can understand them, but the CPU can’t! That’s why an operating system includes interpreters. These are programs that can convert the human-readable programs into machine-readable instructions.

Some programs are compiled. This means that after the programmer writes them, a special compiler is run that permanently converts the program into machine language. This makes them run quickly, but it also means that if the programmer needs to make changes to the program, they need to go back to their source code, make changes, and then recompile the program.

Other programs are interpreted at the time that they’re run by a just-in-time (JIT) compiler. In these cases, the program only exists in its human-readable form until the user goes to run the program. At that moment, the computer runs the interpreter to convert the program into machine language. These programs usually run a bit slower than compiled programs, but they can be easier for less experienced programmers, and even for reasonably confident users, to work with and modify to suit their needs.

Command Line Interface (CLI)

On top of all of the layers of the operating system that run to manage what the computer itself is doing exist the user interfaces. Computers have two main types of user interfaces: the older and more basic is the command line interface. These days you’ll use the command line whenever you run Terminal on a Mac or Command Prompt on Windows, but before the first Mac was introduced in 1984, almost all personal computers only had a command line interface, and users needed to know certain basic commands to be able to do anything with their computers.

The command line lives on today because it is still an efficient way to accomplish certain tasks, and also because, since it requires so much less work from the CPU (and GPU), it can run much faster, and can work well on computers with less powerful components. A lot of servers on the Internet only run a command line interface because the only people who ever sit in front of them and work with them directly are experienced system administrators who are comfortable with the command line. That way all of the computer’s resources can be devoted to responding quickly to requests for web pages or whatever else the server is delivering, instead of drawing a fancy graphical user interface on a screen no one is even looking at. Speaking of which…

Graphical User Interface (GUI)

Most computers these days include a graphical user interface, or GUI, as the main visual representation for users of what the computer is doing, and their way to interact with it. A GUI is bright, colorful and detailed, with icons and windows. This concept was actually invented way back in 1973 but it wasn’t commonly used for personal computers until the Mac in 1984.

Applications (Programs or “Apps”)

On top of all of these pieces of the operating system are the actual applications, also called programs or “apps”, that the user chooses to run and interact with, to do anything from writing a story to watching a video to playing a game to… reading this blog post!