How do Computer Programs Work?

68
rate this page

By Lincoln Armstrong


Photo courtesy Yurayura_nao
Photo courtesy Yurayura_nao

Computers are not smart. The average nine-year-old has spectacular intellect compared to a computer, and is capable of sophisticated prioritizing, decision making and pattern recognition with incredible speed even compared with the most advanced computer processors.

Consider the following example:

A mother wants her daughter to feed their dog, and is going to provide her daughter with instructions on what to do. Let's suppose she provides a robot equipped with the ability to understand English, and with a standard common computer CPU for a logic circuit, with exactly the same instructions. Here are mom's instructions to her nine-year-old daughter:

"I need you to feed the dog after you get the mail. Don't open the front door until you put the dog in the backyard or it will get out. The dish is in the garage. Put the food out back, and use the new can of food I bought yesterday."

Now most parents would agree there are a variety of things kids have trouble doing correctly, and most parents would agree kids can be exasperatingly irresponsible at times. However, what here seems like a routine task is actually an incredible feat of prioritizing and intelligent decision making which the daughter will do effortlessly. In fact, while mom is explaining the instructions, her daughter is instantly sorting and prioritizing a complex series of dependent tasks without even thinking about it.

To illustrate just how remarkable this is, let's see how our robot would follow these instructions. Most programmers can already see the disaster that is about to take place.

First the robot will attempt to feed the dog and fail, because it doesn't know where the dog, food or dish is.

Next, it will attempt to get the mail. For the sake of argument we will assume the robot knows where the mailbox is, and that mail is stored there.

Unfortunately, the dog is now gone, because the robot went out the front door to reach the mailbox.

The robot will note the instruction not to open the front door.

The robot will attempt to put the dog in the backyard and fail because the dog is no longer present.

The robot will retrieve the dog dish from the garage.

The robot will put the food out back.

The robot will retrieve the new can of food, and put it out back as well.

The result is perfectly logical, and the robot has made no errors, logically speaking, except there is a double-ration of food on the ground out back, the front door is wide open and the dog is merging on to the southbound interstate.

While this robot could probably complete all the coursework for the daughter's entire mathematics curriculum through college in under 15 seconds, it is a computer, and computers don't think like people. Computers process instructions absolutely literally. They do not prioritize. They cannot percieve causality or dependency unless instructed specifically to do so. Taking this example even further, it should be noted that this robot has no idea what a dog is, where the "front" and "back" of the house are, or what a dish is for.

But if the daughter is given these same instructions, the dog will neither starve nor run away, one can of food will be used and it will be placed in a dish out back after the mail is retrieved. Why, the mail might even be put someplace where mom can find it conveniently!

When programming a computer, it is important to learn to "think" like a computer, and to arrange the instructions in the computer program in exactly the same way. Computers may be able to process a great deal of information in a very small time interval, but they cannot reason inductively. They don't reach conclusions and they don't rely on hunches.

The most important tool for a computer programmer is the error. One thing computers can do with absolutely flawless efficiency is complain when everything isn't where it's supposed to be. In the previous example, the robot, equipped only with the programming necessary to function as a robot, would have generated the following errors while attempting to follow mom's instructions:

ERROR: Call to undefined function "feed"

ERROR: Undefined object "dog"

ERROR: Undefined object "mail"

ERROR: Undefined object "front door"

ERROR: Undefined object "backyard"

ERROR: Call to undefined function "get out"

ERROR: Undefined object "dish"

ERROR: Undefined object "garage"

ERROR: Undefined object "food"

ERROR: Undefined object "can"

ERROR: Call to undefined function "bought"

The most important of these errors for purposes of this example are "get out" and "bought." User input to a computer is interpreted by the computer as one of two things: data or instructions. There is no such thing as a passive reference, nor is there any such thing as some other interpreter of instructions. The computer's directive is to follow the provided instructions, and it will do its best to try and "get out" or "bought" because those are in the instruction list. The computer doesn't know that the dog might "get out" or that mom "bought" the dog food, and that information is irrelevant anyway, at least as far as the computer is concerned.

It is often very difficult for people to learn to think this way, because human beings subconsciously perform pattern-recognition and reasoning on a level completely beyond the most ambitious computers on a minute-to-minute basis. The daughter knows, for example, what a dog looks like, so she won't feed the cat instead. She knows what a dish is, and understands why it is important that the dog not get out. The robot can only understand these things if it is programmed to understand them ahead of time.

Computer programmers have to make all the decisions for a computer program while they are writing it. If they leave anything out, it will lead to an error, because the computer will be presented with either data, instructions or a lack of instructions for which it has no solution. Provided with no way to continue, the computer will give up and report an error to the user. There are a multitude of ways programmers can instruct computers to make decisions, but the specific parameters of each and every decision must be defined in advance. This is one of the biggest challenges in programming computers.

People learn to make decisions by reasoning and by observing success and failure based on a series of inputs. The colloquial name for this is "trial and error." If it works, people will naturally learn to continue doing what works. If it does not work, people will naturally cease that activity and try something else. They'll probably complain too, but at least that is something they have in common with computers. This goal-oriented approach to reasoning and decision making is something which even "artificially intelligent" computers do very poorly.

Now, let's consider the problem of the same family when the daughter is sixteen and dad is teaching her how to parallel park the car. If he tries to use the same instructions for the robot, let's just hope his insurance is paid up.

RSS for comments on this Hub Small RSS Icon

No comments yet.

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional



working