Learning With Computers
Glenn M. Kleiman
Gentle Introductions To Programming
Everyone should understand the fundamentals of programming; learning about programming is an important step towards becoming computer literate. Without a good concept of programming, one cannot really understand the nature of computers, their capabilities, and their limitations.
In addition, programming is an excellent vehicle for developing thinking skills. Many teachers have reported that when children learn to program, their work in other subjects improves. The teachers attribute this general improvement to the students learning to approach problems more systematically and to pay greater attention to detail.
While they acknowledge its importance, few teachers are experienced programmers, and fewer still are well prepared to teach programming. Many dedicated teachers, realizing the need for computer literacy, are making extraordinary efforts to learn about computers and programming so that they can help their students learn. In this month's column, I discuss two courseware packages which can be extremely valuable for such teachers.
The two packages, Kidstuff and Karel the Robot, are designed to be "gentle introductions to programming." They each contain a simplified programming language and a book with step-by-step lessons for teaching it. With Kidstuff or Karel the Robot, students (and teachers) can learn many of the fundamental concepts of programming. Both packages can also serve as stepping-stones for students who want to go on to learn BASIC, Logo, PILOT or Pascal.
Kidstuff and Karel are not the only existing gentle introductions to programming, and I expect more will be developed in the next few years. Therefore, before turning to the specifics of these two packages, I will discuss in general what we might expect from courseware designed to introduce students to programming.
Structuring Programming
We can think of creating a computer program as involving three main activities. First, we must design the program. Recommended approaches to design have been labeled structured programming, successive refinement, top-down programming, and modular programming. In brief, the recommended approach is to start with the most general aims of the program and successively refine them into more and more specific sub-tasks. We want to design the program so that we can work on one sub-task at a time, handling each in a separate module of the program. The modules are then combined to form the program.
Some languages encourage structured programming more than others. For example, in some languages, variables can be local to a module, so you do not have to worry about using the same variable name in different modules of a program. Introductions to programming should encourage structured programming so that students acquire proper habits from the beginning.
The second main activity of programming is to code the instructions — translate them into a language the computer can follow. We can discuss computer languages in terms of three types of elements: (1) Commands, such as those which print words and text on the screen, accept inputs from the users of programs, perform mathematical operations, and manipulate text; (2) Control Elements, which are used to iterate (repeat) sets of commands (e.g., FOR/NEXT loops in BASIC), follow commands when a given condition is true (e.g., IF-THEN conditionals), branch to other parts of the program (e.g., GOTO), or use a module (subroutine or procedure) and then return to the current part of the program (e.g., GOSUB); and (3) Data Structures, or ways information can be organized and stored (e.g., simple variables, subscripted variables, hierarchical trees).
No matter which language is being taught, in introducing programming to students we generally use a few simple commands, control structures for iteration, conditionals, branching and modules, and only the simplest (if any) data structures. These are the elements we would expect to make up a simplified language.
The third activity of programming is testing and debugging. Beginners often suffer a great deal of frustration in finding and correcting errors. Some programming languages facilitate debugging by such things as catching syntax errors as the program is entered and allowing the program to be run one step at a time so it can be analyzed carefully. Languages designed to introduce programming should contain such debugging aids.
Kidstuff and Karel the Robot provide simple languages so students can learn programming fundamentals with a minimal amount of frustration and delay. They can help students master recommended principles of program design while making the coding and debugging stages as painless as possible.
Kidstuff
Kidstuff, by Thomas R. Smith, is suitable for children as young as first or second grades. It is also appropriate as an easy introduction to programming for older children. Kidstuff operates on PET computers, and a version for Commodore 64 computers is being developed.
The commands of the Kidstuff language let children write programs to create pictures on the computer screen and play music. The language itself is a mix of turtle graphics-like commands (e.g., DF for draw forward, TR for turn right), modules like those in Logo, branches and loops similar to those of BASIC, a command to use any of the PET graphics symbols, a music command, and special features to aid debugging.
This sounds like a mish-mash, but it has been blended into a coherent teaching tool. A particularly good feature of the Kidstuff package is the manual, which contains 13 tutorial lessons, demonstration programs, and suggested projects. The Kidstuff language and manual make it possible for all teachers to introduce programming to their students. The manual can be an extremely valuable aid for teachers who are not themselves knowledgeable about programming.
The commands of the Kidstuff language are:
DF - draw forward
JF - jump forward without drawing
TR - turn right 90 degrees
TL - turn left 90 degrees
P - select a symbol for drawing (any letter, number, or PET graphics symbol can be used)
B# - play a note of a specified pitch and duration
There are also two control elements similar to GOTO branches and FOR/NEXT loops in BASIC, as well as two simple variables, X and Y.
In addition, Kidstuff lets you "teach" the computer new commands. For example, you can tell the computer how to draw a square of size 5:
TO SQUARE | |
BL | [begin a loop] |
DF 5 | [draw forward 5 steps] |
TR | [turn right 90 degrees] |
RL 4 | [repeat the loop 4 times] |
Once this is entered, SQUARE can be used just like any of the built-in commands. This capability, similar to the use of procedures in Logo, encourages modular programming.
Kidstuff has several features to facilitate debugging. First, syntax errors are caught as the program is entered, and friendly, clear error messages are given. It's much easier for children to deal with an error message which says "OOPS! THE COMPUTER DOESN'T UNDERSTAND" or "OOPS, LINE NUMBER ERROR" than messages such as "SYNTAX ERROR" or "ERROR 112" found in other languages.
Also, Kidstuff has a WALK option which tells the computer to follow the instructions in the program one at a time. When walking, the computer displays an instruction, follows it, and then waits for the child to press the SPACE BAR before going on to the next instruction. This option, similar to TRACE or STEP options in some versions of other languages, is very valuable for helping children analyze their programs and find bugs.
This simple language (I have described all of it) can introduce children to most of the fundamental concepts of programming. The only main concept missing is that there are no conditional (IF-THEN) commands.
Kidstuff is not a powerful language. It is very limited in the number of variables, loops, and new commands possible. However, these limits do not distract from its intended purpose. Once children find the limits of Kidstuff constraining, they are ready to go on to learn BASIC or Logo. Having mastered Kidstuff first, they will find it easier to learn other languages.
Karel The Robot
Karel the Robot, by Richard E. Pattis, is designed for high school and college students. It teaches concepts of structured programming and can serve as an excellent bridge to learning Pascal, a language now taught in many colleges and universities and becoming increasingly popular in high schools. There is a book about Karel the Robot's language and a "simulator" for Apple II computers that lets you explore the language.
Karel the Robot's world consists of a grid of streets and avenues, walls which block Karel's paths, and beepers which Karel can pick up, carry, and place on street corners. Karel, like all well-behaved robots, obeys simple commands. These are:
MOVE – go forward 1 block
TURNLEFT – pivot 90 degrees to the left
PICKBEEPER – pick up a beeper
PUTBEEPER – put a beeper on a corner
TURNOFF – end the program
In addition, Karel's language contains control elements for repeating instructions (the Pascal ITERATE-TIMES and WHILE-DO commands), conditional tests (IF-THEN-ELSE), and grouping instructions into blocks (BEGIN/END). It also lets you define new instructions. These are some of the most important elements of Pascal, and Karel's language also uses Pascal-like syntax.
The Karel the Robot book contains six chapters which present Karel's world and language with example programs, suggested problems, and valuable information about good programming practices. The book is very well done and can be used without the simulator. However, the simulator adds a great deal.
The Karel simulator has a number of excellent features. After you enter your program, it is checked for syntax errors, and useful diagnostic messages are given. There is even a spelling check routine – for example, if you type "MIVE" the computer will display a message saying "I ASSUME YOU MEAN MOVE". Once your program is syntactically correct, you can create the world in which you want Karel to run your program.
You assign Karel a starting location and specify the locations of walls and beepers. You then have many options as to how to run the program. For example, you can select high, medium, or low speed, and you can have Karel leave a trail as he moves. Karel's world is stark, with Karel looking like an arrowhead on the screen. But watching Karel move clearly shows how your program operates.
A "monitor mode" option is an extremely valuable learning aid. In this mode, you can control exactly how Karel proceeds through your program. You can tell Karel how many steps to execute; he does so and then pauses for your next command. At any point you can tell Karel to run the program in reverse, display each command as it is executed, run the program until reaching a specified command, and use other options which make it easy to analyze and debug programs.
Karel the Robot is a well-designed, gentle introduction to programming, as well as a solid stepping-stone for people interested in learning Pascal.
Course disks, which contain solutions to all the problems in the Karel book, are available for $150. The Karel the Robot book, published by John Wiley and Sons, is also available separately.
Kidstuff
Thomas R. Smith
P.O. Box 345
Dedham, MA 02026
$59.95 cassette
$69.95 disk (including backup)
Karel The Robot
Cybertronics
999 Mount Kemble Ave.
Morristown, NJ 07960
$85