Introduction
What is a computer anyway?
Computers are everywhere, and most of us use them everyday. Unlike a few decades ago, they are now small enough to be inside our cars, our appliances, and even our bodies. We typically carry one with us in our phones, and often wear them on our wrists in our watches. We interact with computers constantly - for instance, to help us be more productive at work, or to help us relax better at home.
Because computers are used in so many ways, it can be hard to provide a definition of what a computer is. In this text, we will define a computer very simply. A computer is a machine that takes input and produces output. While some definitions of what a computer is mention they are electronic devices, we prefer the more generic term “machine”, both for historical reasons (which we will talk about in the next section) and for the connotations it infers.
When people hear the word “machine”, they tend to have an idea of a mechanical object that does some job for humans. In fact, early attempts at building computers were mechanical. Charles Babbage for instance, designed several “difference engines” that could solve certain mathematical problems with only gears and other mechanical parts. Babbage designed his first computing machine in the 1820s, but even before him people had hoped to create machines that could perform computations automatically. Unfortunately, actually building these devices wasn’t possible at the time, due to cost and manufacturing constraints. Even then, these devices were only designed to solve certain problems, and adapting them to solve other problems was sometimes impossible.
A brilliant mathematician named Alan Turing developed the ideas that led to computers we have today. Turing wanted to create machines that were flexible, and able to be used for many different types of problems. To do so, he needed to figure out some basic operations that machines could perform, and determine how those basic operations could be combined to solve mathematical problems. The machine he envisioned we now call the Turing Machine. To be clear, Turing never built such a machine. It was simply theoretical. But, it defined the operations that computers needed. It has the following parts:
- An infinitely long tape, divided into cells. Each cell can hold either a 1, a 0, or be empty. We can give each cell a number so that we know where we are on the tape.
- A read/write head. This can read or write only to the cell below it, then move left or right across the tape.
- A set of rules. The rules were statements like “if you are at location 42 and there is a 0 in the cell, change it to a 1 and move to cell 43”.
Notice that the set of rules simply define a mechanical process. Turing was able to prove that with certain sets of mechanical processes a machine could perform a lot of different computations.
An Example
As we mentioned before, the values on the tape are 0, 1, or blank. If we represent numbers with just zeroes and ones, we are dealing with a binary number system. Binary simply means “two”. You are probably used to representing numbers in the decimal system; in that system numbers are represented with the digits 0-9. There are 10 digits we can use (decimal means based on the number ten). Since we only have the digits 0-9, when we use all of those digits we add another decimal digit, starting back over at 0. So for instance, when we count 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, we then start back over at 0 and add another digit (the digit 1) to the left. This gives us the number 10. Binary works the same way, except that we can only use the digits 0 and 1. So 0 in binary would be 0 in decimal, 1 in binary would be 1 in decimal, but then to get 2 we need to add a digit. Two in binary would be 10.
In decimal, we often talk about the ones place, the tens place, or the hundreds place. For instance, if we had 123, we would say there is a 3 in the ones place, a 2 in the tens place, and 1 in the hundreds place. Notice that we go from right-to-left, starting with the 3. If we start counting and label the ones place digit 0, then 2 is digit 1 and 1 is digit 2. Mathematically, we are saying:
$$ = 3 * 10^0 + 2 * 10^1 + 1 * 10^2 $$ $$= 3 * 1 + 2 * 10 + 1 * 100$$ $$= 3 + 20 + 100$$ $$= 123$$
This works the same way with binary. If we had the number 11001, we could perform the same math:
$$= 1 * 2^0 + 0 * 2^1 + 0 * 2^2 + 1 * 2^3 + 1*2^4$$ $$= 1 * 1 + 0 + 0 + 1 * 8 + 1 * 16$$ $$= 1 + 8 + 16$$ $$= 25$$
How does this relate to what Turing designed? Well, remember that what Turing was trying to do was to mechanize computation using the concept of the Turing machine. Let’s say - for instance - that we wanted to multiply a number by 2. We could do so with the following rules:
- Start at the left-most digit of your number.
- Move right until you encounter a blank.
- Put a 0 in that blank.
Let’s see if it works. Imagine we start with the value 1101 (this is decimal 13):
$$11010 = 1 * 2^1 + 1*2^3 + 1*2^4$$ $$ = 26$$
It works! Now, this is a trivial example, but it illustrates what we mean when we say that computers are machines. All they do is follow a set of rules that make changes to the "tape". You've probably figured out by now that modern computers don't have tape to store values in. Instead, they use electronic memory. Instead of a list of rules written down somewhere, they have an **instruction set** of operations built into their processors. But, the same principles apply.