Darn bugs! darn bugs

Nobody likes to talk about computer bugs. That's why this lesson is so short. All I ask you to do is to read it I won't ask you to write programs with bugs!

1. What is a bug?

The origin of the word bug in computer jargon is often attributed to an actual incident where a moth was found inside Harvard University's Mark II computer; apparently this moth had caused the computer to stop working. It was found by the team headed by renowned computer scientist, mathematician, and young naval officer Grace Murray Hopper, who went on to invent the concept of compiler languages in computer programming. Dr. Grace Hopper eventually rose in the U.S. naval hierarchy to the rank of Rear Admiral.

The moth was preserved, taped into Hopper's log book, as shown below. Interestingly, the log book included a note saying, "First actual case of bug being found." as you can see.

first bug

Actually, the word bug in a technological context is attributed by the Oxford English Dictionary to Thomas Edison. According to the Oxford Dictionary, the following text can be found in the March 11, 1889 edition of the Pall Mall Gazette:

Mr. Edison, I was informed, had been up the two previous nights discovering 'a bug' in his phonograph - an expression for solving a difficulty, and implying that some imaginary insect has secreted itself inside and is causing all the trouble.
It thus appears that the original 'bug', though it was indeed an insect, was in fact imaginary.

Unfortunately, computer bugs, while they are not insects, are also not imaginary.

2 Dealing with bugs

In computer jargon, a bug is an error that causes a program to behave in an unexpected way. If you are writing computer programs, you are going to have bugs in them sooner or later - everybody does. Good programmers seek to "remove" bugs or "fix" them as soon as they find that their program behaves unexpectedly.

RUR-PLE has been designed to help you find bugs.

  1. The "oil leak" of the robot, leaves a trace behind that allows you to see (trace) the instructions followed by the robot.

    simple left turn

  2. Each instruction (like pick_beeper() below, which we have not introduced yet) is highlighted in the program window as it is about to be executed by the robot.

    highlighted instruction

  3. You can "pause" a program as it is running by pressing the pause button pause button. This is similar to what people refer to as setting a breakpoint in a computer program.

  4. You can "step through" a program, one instruction at a time, by pressing the (execute one instruction and pause, or step) button step button.

  5. For long-running programs, you can actually speed things up by pressing the speed button speed button. You can then run the program quickly, pause it when you reach the point near the unexpected behaviour (the "bug"), and then carefully step through each instruction one at a time.

  6. If you find that you started a program and you want to stop it before it reaches the end, you can always press the stop button stop button.

  7. At the bottom of the screen is a status bar which displays: 1) which program is loaded; 2) the status of that program; 3) the number of beepers carried by the robot; 4) which world file has been loaded.
    status bar
    We will see more later about beepers and world files.

  8. If you want to restart your program with the robot back at its original starting point when you first loaded a world file (which we have not explained how to do yet), you will need to press the reset world button reset button.

This should be more than enough for now. Later, I will show you other tricks to use in trying to find and fix bugs.

previous Beepers - home - Building walls next
../images/SourceForge.net Logo