E Pluribus Unum
StarLogo is an offspring of Logo, the programming language devised in the 1960s by Seymour Papert of MIT and Wallace Feurzeig of Bolt, Baranek and Newman. The best-known feature of Logo is turtle graphics, a scheme for drawing pictures by issuing commands to a "turtle" that carries a pen over a plane. The first turtles, which actually predated Logo by two decades, were mechanical devices that crawled on the floor or a tabletop. Today most Logo systems provide a "virtual turtle" on a computer display screen.
StarLogo extends the turtle-graphics metaphor in three ways. First, it accommodates thousands of turtles rather than just one or a few. Second, the turtles can interact with one another and with their environment; for example, one turtle might deposit a chemical, which would then be sensed by other turtles. Third, the environment itself becomes more than a passive background for the simulation. The landscape where the turtles live and move is made up of "patches," which can be assigned various properties. In effect, the turtles wander over a two-dimensional cellular automaton, which would be a powerful computing device even without the turtles.
Here is the Logo idiom for drawing a circle:
repeat 360 [forward 1 left 1]
The turtle repeatedly moves one step forward and turns one degree left until it comes back to its starting point. The same procedure would work without alteration in StarLogo, but other approaches to circle drawing make better use of StarLogo's distinctive facilities. The emphasis in StarLogo is less on pens and drawing and more on creating patterns with the turtles themselves. Here is one way to create a circle in StarLogo:
setheading random 360
The idea is to spawn a large number of turtles, all initially at the origin of the plane, and then send them marching 40 steps in random directions. The result is a ring of turtles with a radius of 40 units.
The first version of StarLogo was written for the Connection Machine, the fine-grained parallel computer created by Danny Hillis. The Connection Machine was particularly well suited to the task because its thousands of processors allowed each turtle to run its own independent program. But not everyone has a Connection Machine in the basement. Current versions of StarLogo run on the Macintosh computer, where parallel execution has to be simulated on a single processor. Even so, programs with several thousand turtles run with acceptable speed.
Papert developed Logo as "a language for learning," and in particular as a language that would help to acquaint children with the enchantments of computer programming. Resnick also has an interest in pedagogical matters, but he suggests the ideal audience for StarLogo is somewhat older than that for Logo Classic: He gives the language a PG-13 rating. Many interesting StarLogo programs have been written by high school students, and I have found that even adults can pick up the basic principles with only a little effort.
» Post Comment