FRIENDS OF THE TURTLE
David D. Thornburg, Associate Editor
PILOT And Logo – A Tale Of Two Languages
PILOT and Logo are two of the most popular user-friendly computer languages available for personal computers. Because Atari PILOT and Apple SuperPILOT both contain a powerful turtle graphics environment, many people wonder if PILOT might not be a substitute for Logo.
As I will show, Logo and PILOT are quite different languages. Although they can be used for many of the same applications, each language has special features that make it more appropriate for some applications than for others. The goal of this article is to provide enough information about both languages to aid someone who is trying to decide which to use. I will assume that you are already familiar with turtle graphics.
PILOT stands for Programmed Inquiry, Learning Or Teaching. It was so named by its developer, John Starkweather, because he wanted to create a programming language that easily allowed teachers to generate computer-aided instructional materials. Research in the late 1960s by Dean Brown showed that PILOT was also a good programming language for children.
The key to PILOT'S appeal is its simple command structure and powerful ability to manipulate text-oriented material. At its core, PILOT has only eight commands, yet these eight commands allow the creation of quite sophisticated programs. The core commands for PILOT are shown below:
|T:||Types text and variables on the screen.|
|A:||Accepts input from the keyboard.|
|M:||Matches words or phrases against the result of the most recent accept command.|
|J:||Jumps execution to a label.|
|U:||Uses a labeled procedure.|
|C:||Computes the value of a variable.|
|R:||allows Remarks to be added to a procedure.|
|E:||Ends a program or procedure.|
Notice that none of these commands has anything to do with graphics. The incorporation of turtle graphics in PILOT is a fairly recent event. Also, most versions of PILOT have additional text manipulation commands that add significantly to its power.
Core PILOT'S most powerful command is M:, the match command. To see why this command is so powerful, consider the following PILOT procedure:
*QUESTION1 T: WHAT GROWS ON TREES? A: M: MOSS, LEAVES, BUGS, INSECTS, NEEDLES TY: YOU ARE CORRECT TN: ARE YOU SURE? LET'S TRY AGAIN. JN: *QUESTION1 E:
This PILOT procedure works in the following way. First, a question is typed on the screen. The user then types a response that is saved in the "accept buffer." The match command then checks to see if any of the words, MOSS, LEAVES, etc., appear anywhere in this buffer. If there is a match, a "yes flag" (Y) is set to be true and a "no flag" (N) is set to be false. The execution of any PILOT command can be made conditional on the status of these flags by entering Y or N after the command name. For example, the command TY: will print on the screen only if the yes flag is true. The JN: command causes the procedure to be used over again if the user's response is not matched.
As a result of PILOT'S ability to manipulate words and phrases, many of the early uses of PILOT by children involved the creation of word games and "poetry generators."
What About PILOT Graphics?
As mentioned, graphics is a recent addition to PILOT. Turtle graphics is incorporated through the use of special commands. In Atari PILOT, for example, this command is GR: followed by specific graphics instructions. The fundamental graphics commands allow the turtle to be moved in its present heading or to have its heading changed.
Here's a list of the more commonly used Atari PILOT graphics commands:
|GR: DRAW x||Draws a line of length x in the present heading.|
|GR: TURN x||Rotates the turtle by x degrees.|
|GR: PEN UP||Raises the turtle's pen.|
|GR: PEN YELLOW||Sets the pen color to yellow and sets the pen down.|
|GR: GOTO x, y||Moves the turtle to absolute coordinates x, y.|
|GR: TURNTO x||Rotates the turtle to absolute orientation of x degrees measured to the right of straight up.|
These commands (and several others) allow the creation of procedures that draw complete figures. For example, the PILOT procedure shown below draws a square 50 units on a side:
*SQUARE GR: 4(DRAW 50 ; TURN 90) E:
To use this procedure, one would type:
Logo is a computer language that was designed by Seymour Papert to be an easy, yet powerful tool which would let children use the computer to explore topics on their own. While designed to be used by children, Logo is a user-friendly version of the tremendously powerful language, LISP. Since LISP is the language of choice for many researchers in the field of artificial intelligence, clearly Logo is a programming language for adults as well.
The key to Logo's appeal is its simple syntax (compared with LISP) and its ability to manipulate data structures called lists. A list is a collection of words, Logo commands, numbers, or other lists. Logo allows lists to be constructed, modified, examined, reordered, and (if the list consists of Logo procedures or primitive commands) executed. Here are some core Logo commands which are comparable to the core PILOT commands:
|Prints a list of text on the screen.|
|READLIST||Reads a list from the keyboard.|
|MEMBERP||A predicate that matches a word against the elements of a list.|
|MAKE||Assigns (or "binds") a number, word, or list to a variable named by a word.|
|END||Ends a procedure.|
|FIRST||Returns the first element of a list.|
|BUTFIRST||Returns all but the first element of a list.|
|LAST||Returns the last element of a list.|
|BUTLAST||Returns all but the last element of a list.|
Notice that none of these commands has anything to do with graphics. Turtle graphics was incorporated into Logo after the language had been in use for a while. The list of Logo primitives shown above is quite incomplete, but it allows us to build a procedure comparable to the QUESTION1 procedure we wrote in PILOT:
TO QUESTION1 PRINT [WHAT GROWS ON TREES?] MAKE" ANSWER READLIST TEST MEMBERP FIRST : ANSWER [MOSS LEAVES BUGS INSECTS NEEDLES] IFTRUE [PRINT [YOU ARE CORRECT]] IFFALSE [PRINT [ARE YOU SURE? LET's TRY AGAIN] QUESTION1] END
This procedure performs a function similar to that of the PILOT procedure except that it only looks to see if the first word on the answer is contained in the answer list. The commands following the words IFTRUE are executed only if the result of TEST is true. If the result is false, the commands following IFFALSE are executed instead. Notice that a Logo procedure is treated just as if it were a Logo primitive. To execute the procedure QUESTION1, you merely type its name.
As with PILOT, many of the early uses of Logo by children involved the creation of word games and poetry.
What About Logo Graphics?
A list of the more common Logo turtle graphics commands is shown below:
|FORWARD x||Draws a line of length x in the present heading.|
|RIGHT x||Rotates the turtle by x degrees.|
|PENUP||Raises the turtle's pen.|
|PENDOWN||Sets the pen down.|
|SETPOS x y||Moves the turtle to absolute coordinates x, y.|
|SETHEADING x||Rotates the turtle to absolute orientation of x degrees measured to the right of straight up.|
These commands (and several others such as BACK and LEFT) allow the creation of procedures that draw complete figures. For example, the following procedure draws a square of any size:
TO SQUARE : SIZE REPEAT 4 [FORWARD : SIZE RIGHT 90] END
To use this procedure to draw a square 50 units on a side, one would enter:
Differences Between Logo And PILOT
The previous sections have suggested that PILOT and Logo are similar in application areas and syntax. In fact, there are some major differences between the languages that may cause one to be clearly the language of choice for a particular task. For example, PILOT makes it very easy to create programs in which the contents of variables are printed along with text. Also, the match command will compare each element of a list with the entire response. In Logo, you would have to write a procedure to do this.
Another important feature of PILOT is its compactness. Most Logo implementations require large amounts of RAM. Most (but not all) versions of PILOT will operate in 16K of RAM with plenty of space left for the user's program.
In terms of overall symbol manipulation, Logo is the more powerful of the two languages. The ability to write programs that generate other programs is of great utility when constructing environments that "learn from experience." The fact that user-defined procedures are treated exactly as if they were Logo primitives gives Logo a feature called extensibility. This means that you can add new words to Logo's vocabulary (as we did with QUESTION1 and SQUARE). There is no need in Logo for the jump or use commands. To execute a procedure, you just type its name.
Logo also supports local variables. This means that the value associated with a variable is assigned to the specific procedure (and level) in which it is used. This allows you to write procedures that use themselves recursively. For more information on this topic, you might want to read the "Friends of the Turtle" columns on recursion that appeared a few months back.
Logo's turtle graphics commands are, perhaps, easier to grasp than PILOT'S, but there are indications that this will not always be the case as new versions of PILOT are likely to become more "Logo-like."
Apart from these differences, Logo and PILOT both encourage a procedure-oriented programming style that makes complex programs easy to read and correct.
I use both languages regularly and find that I would be reluctant to abandon either one. Your application areas might indicate that one of these languages has a clear advantage over the other. No matter which you choose, you will be using a language that allows the creation of very sophisticated and powerful programs.
Notes From All Over
I have just heard from my Argentinian friend, Horacio Reginni, who has just started the Asociacion Amigos de Logo (Logo Friends Association) to promote the development of Logo centers, sponsor meetings, and spread information about Logo all over the world. The association can be reached at 2969 Salguero St., Buenos Aires, 1425 Argentina. True Logophiles will be interested in attending their first International Logo Conference in Buenos Aires on September 16-18. Registration is only $25. As for the air fare ....