It's All Just Numbers

It's All Just Numbers

Robbert Haarman

2010-12-11


Introduction

These days, many people work with computers on a daily basis. Many of us own computers, and many of us even perform various degrees of maintenance on them. Despite this, comparatively few people have a solid understanding of how computers actually work. To many, computers work as if by magic. This makes it difficult to understand what capabilities a computer is likely to have, difficult to understand and solve any problems that may occur, and, on a personal note, difficult for me to explain the work I do. In this essay, I propose thinking of computers as performing simple operations on numbers. This is a simple mental model that doesn't require much prior knowledge of computers, but is also accurate enough that it explains many of the behaviors and limitations of computers.


What You See Is an Illusion

When you interact with your computer, you probably use keyboard and mouse to enter text, click buttons, open and close windows, etc. It is as if the windows and buttons you see, the text you enter, and the images that the computer displays are physically there. This is an illusion. Your computer does not have any notion of windows, buttons, or images. This is significant, because things, both good things and bad things, can happen without there being any obvious relation with what you see on the screen. You've probably experienced this: suddenly, the normal operations don't work anymore; buttons that don't do anything when clicked on, windows that cannot be closed, notifications popping up about updates having been downloaded, without you having taken any action, etc. Some of you might even have experienced the Blue Screen of Death, or sudden reboots: suddenly, all your windows and text and images are gone, replaced by a blue screen with an error message, or the display that indicates your computer is starting up. The illusion has been shattered.


Memory

You may have heard that, inside a computer, everything is ones and zeroes; on or off. This is sort of true, at an electrical level. However, that is at a lower level than I want to go. What a computer actually does is process numbers. The numbers the computer operates on are stored in its memory. A computer has various types of memory; CDs and DVDs are memory, USB memory sticks are a kind of memory, etc. The one I'm interested in here is the working memory, so named because it contains the numbers the computer is currently working on. This memory is almost always volatile, meaning that if you turn off the computer, if the battery runs out, or there is a power outage, the contents of the memory are lost. Probably, you've experienced situations like that.

This working memory basically consists of a large number of cells (easily in the trillions), each of them capable of holding a number. So the contents of the first four cells of the memory might be 42, 123, 688, and 120. What do these numbers mean? Well, nothing, really. They're just numbers. They only start to be meaningful when you start interpreting them. For example, if you interpret the contents of people's bank accounts, you might conclude that one person has 42 dollars in his account, whereas the next person has 123 dollars, and so on. So the second person has more money than the first one. But maybe the numbers are debts, instead. Or maybe they have completely different meanings. Maybe they don't have any meaning at all, but are just there because a failure in the memory put them there.


Instructions

One possible interpretation of the numbers in the memory of the computer is as instructions. You can imagine making up a sort of code, where 1 means "take a step forward", 2 means "turn left", etc. Computers work that way. They read numbers from memory, and do what the numbers tell them to. After they read one number and do what the number tells them to, they read the number from the next cell in memory (unless, of course, the number they just read told them to do otherwise), and do what that number instructs them to do.

The instructions that can be given to a computer are simple operations on numbers. The computer can do things like adding numbers, comparing if two numbers are equal, etc. It can also change the contents of memory cells, or specify that the next instruction should be read not from the next cell after the last instruction, but from a different cell. Which cell to read a number from, or which cell to write a number to, is specified by an address, which is itself just a number. The first cell has address 0, the next one address 1, the next one after that number 2, and so on. The important thing is, it's all just numbers. There's no concept of windows or even text, as far as the computer is concerned.


Conjuring Up the Illusion

So what about the windows and buttons and text and images? Are they just numbers, too? Indeed, they are. In fact, the image you see on the monitor consists of a large number of dots, called pixels, short for pixel elements. Each pixel has a color, and the color is ... a number. Basically, the computer puts images on your screen by writing a lot of numbers to a lot of memory cells, that are then interpreted as colors and displayed on the monitor (by another kind of computer). In a similar way, a computer plays sound by feeding a lot of numbers to a computer which interprets them as voltages to feed to a speaker, and computers are used to control car brakes and fly airplanes in similar ways.


Programming

When people like me program computers, what we're really doing is putting a lot of numbers in the computer, that will (hopefully) tell the computer to do what we want it to do. Usually, we don't actually input the numbers corresponding to the instructions that the computer understands (although this is certainly possible). Instead, we input text, much like one might input an email. Internally, of course, this text consists of numbers, and there are programs which will convert these to the numbers the computer understands. We get to enter and see vaguely English-like words, which we understand; the computer gets to see a lot of numbers that it can understand, and that's how we're able to get the computer to do what we want.

Since the numbers that we enter are, at first, completely meaningless to the computer (much as they would be to us, without being told how to interpret them), there are various ways to translate these to numbers that do have a clear meaning to the computer. This gives rise to a multitude of programming languages, each with their own merits and downfalls, which are subject to much and heated discussion.


Bugs

Before, I've said that memory contains numbers, and that these numbers are meaningless until you interpret them. They could be account balances, and they could be instructions to the computer. So what would happen if the computer mistook a bank account number for an instruction? Well, it depends on what the number means, when interpreted as an instruction. It's a safe bet, however, that this instruction is not going to be constructive to the illusion of images and text that the computer displays. The next instruction will worsen things, and so on, until, eventually, anything might happen, but it usually means your computer crashes and you lose any work you hadn't saved.

How could it happen that the computer starts misinterpreting the numbers in its memory? Well, there is a slight chance that something goes wrong with the hardware; perhaps it is defective, or perhaps a bit of radiation (which is all around us) changed the value of some number in memory, causing the wrong thing to happen. Vastly more likely, however, is that the person who wrote the program that you're running made a mistake, which caused the wrong numbers to be present in the program you were running, causing the computer to dutifully do the wrong thing. This is known as a bug; probably in an attempt by us, the programmers, to make it look like it wasn't our fault; a bug got in the machine!


Taking Over Another Computer

Often, bugs can be exploited by malicious people to crash or take control of another system. Again, this is easy to understand if you keep in mind that everything the computer operates on consists of numbers. A program that displays an image has to load this image (at least parts of it) into memory. Doing so overwrites whatever was previously in those memory cells. If the program doesn't take proper care of things, it may be possible that things get overwritten in such a way that the computer starts interpreting whatever numbers are in the image as instructions. Someone who knows how to could use this to create an image that causes your computer to do whatever he wants, for example, sending out spam. Of course, this trick works not only for images, but for anything that has numbers in it. That is to say, anything at all.

This is but one example of how your computer might be taken over by an attacker. However, it is about the most mysterious type of attack that does commonly happen. How can viewing an image give people access to your computer? Well, you see, you're not really viewing an image as far as the computer is concerned; you're feeding it numbers, and these numbers might mean anything at all. However, keep in mind that (barring hardware failures, which are really quite rare), these sorts of failures are only possible due to faulty software. If the software hadn't contained the bug that allowed the attacker to cause your computer to misinterpret the numbers it sees, nothing bad would have happened.


Conclusion

I hope this essay has given you a better understanding of why computers behave the way they do. It's all just numbers and suggestions, or comments, please do not hesitate to contact me or post a reply.

Valid XHTML 1.1! Valid CSS! Viewable with Any Browser