Clever Humans

Logo

Clever Humans do the darnedest things!

Categories

24 September 2006

Like My New Logo?

by Patrick

When I was in college I had a friend who had a box turtle. She kept it in a terrarium, which is like a three dimensional box without a top. It was just like this except for the part that it was really small and fit on her desk.

Her turtle’s name was Atrocious. My vote was Gamera, but I guess everyone with a box turtle calls it Gamera.

I would stand in front of Atrocious’ terrarium, stare into her dumb reptilian eyes, and say things like:
    FORWARD 100
    RIGHT 90

Like my old girlfriend, Logo is a programming language with a pet turtle. Unlike my old girlfriend, Logo follows the exact instructions that you give it.

Logo may be the only programming language with a pet.  Well… I suppose C# has VB.Net. But I’m not sure if that counts.

Logo is often considered a good language for young children to learn. It is a graphically oriented language that has very simple commands. It also has a command interface interpreter so children can immediately see the results of what they type.

All the examples in this post were created using MSWLogo, one of the many flavors of Logo currently available.

When you first start MSWLogo you are presented with a blank white page with a triangle in the middle.

This triangle is called a turtle. Why is it called a turtle, you may ask? Well, duh, cause it looks like a turtle! Actually, the real answer is because the Logo programming language was invented before computers could make realistic turtles.

Personally, I would have called it the B-2.

The above square was made by typing in these commands:

FORWARD 100
RIGHT 90
FORWARD 100
RIGHT 90
FORWARD 100
RIGHT 90
FORWARD 100
RIGHT 90

As you can see, the syntax is very obvious and verbose. The commands are complete english words.

The FORWARD command causes the turtle to move forward the specified number of “turtle steps.”

Yes, that’s right. Turtle. Steps. Not pixels, or picas or twips or any other more common measurement. But turtle steps. This really is a language created for children. Not that the words “Pixels,” “Picas,” or “Twips” actually sound any less childish.

Mommy! Mommy!  Look, I made a house!

The commands for the house are:

cs
left 180
forward 100
left 90
forward 100
left 90
forward 100
right 90
forward 20
left 180
forward 140
right 120
forward 140
right 120
forward 140

As you can see, Logo is not a case sensitive language. However, that was a lot of typing. I have no desire to type it again. This house will never have neighbors if I have to type all that in again.

Fortunately, Logo also has the concept of subroutines. I can create a routine called HOUSE by entering the following commands:

EDIT “House

to House
left 180
forward 100
left 90
forward 100
left 90
forward 100
right 90
forward 20
left 180
forward 140
right 120
forward 140
right 120
forward 140
end

Now, to draw a house, all I need to do is type
          HOUSE

Now how about giving my house a neighbor?

As you can see, my neighbor’s house is blue. Here is how it was done:

cs
setpencolor 0
house
home
setpencolor 7
setpos [-200 0]
setpencolor 1
house

This introduced new commands. Like everything in Logo, all of them are pretty self-explanatory. The color numbers map to the old 16 colors that stone age computer screens used to have. How quaint!

Is Logo still a useful language for children to learn? When I was a child, Logo was taught to us in 7th and 8th grade. Today, I would expect 8th graders to know Python or Ruby. Logo might be a good language for 4th graders to learn.

tags: