Logo – A programming blast from the past?

September 14th, 2007 | Categories: programming | Tags:

One of the great things about browsing the Internet is that you never know where you are going to end up. Recently, I have taken to looking at new entries on the Wolfram Demonstrations page (mentioned in an earlier blog post) and, if I find something interesting, I follow it up. By doing this I have discovered all sorts of delightful (but, it has to be said, mostly useless) mathematical tidbits.

My most recent find is a demonstration entitled ‘Polygons arranged in a circle‘ which produces some attractive looking flower-like designs by drawing a set of identical regular polygons arranged in a circle. The instant I set eyes on the preview I had a sense of deja-vu. Not only had I seen such patterns before but I had written the code to produce them when I was a child of around 10 on a BBC Micro using the Logo programming language. These were probably among the first codes I had ever written in my life and started a lifelong fascination with programming that is still with me today.

The Logo programming language is a dialect of Lisp that was developed in the late 60s by Daniel Bobrow and Wallace Feurzeig of BBN in collaboration with Seymour Papert of MIT. You may not have heard of BBN but, along with developing Logo, they were the company that developed the Arpanet – widely held to be the precursor of the internet. They also put the @ symbol in email addresses by the way.

Back in the 60s it was much harder to program computers than it is now and Logo was developed as a learning tool for children. It was designed not just to help teach programming but also to help teach concepts from mathematics such as geometry and algebra. For more about the history of Logo you might like to read Wallace Feurzeig’s ‘The LOGO Lineage’ -originally published in 1984 as part of the book ‘Digital Deli’.

Although it is a very powerful language (and to get an idea of just how powerful take a look at Brian Harvey’s set of 3 Logo-centric computer science books available for download from here), Logo is best known for it’s Turtle Graphics. The turtle was originally a robot that moved around the floor, holding a pen and controlled by a computer using Logo. These days it is represented by a sprite on a computer screen. Using Logo and the turtle you can write programs to draw anything you like. The commands are simple – for example:

forward 20 – moves forward 20 units
right 90 – rotates to the right 90 degrees
repeat n [ ] – repeat the commands in the brackets n times.

So to draw a square

repeat 4 [forward 20 right 90]

we can also write subroutines – here is one that will draw a hexagon

to hexagon
repeat 6 [forward 20 right 60]
end

We are now just one step from reproducing the type of graphics in the Mathematica demonstration

to flower
repeat 30 [ hexagon right 12]
end

running the command ‘flower’ will produce the pattern below.

With a little thought (and one or 2 extra commands not mentioned here) you can modify the code to produce any of the designs in the Wolfram Demonstration. This is all well and good but how do you get Logo on your PC? I found a great implementation called Berkeley logo – there are many others but this one seems to be among the best. If you have Ubuntu Linux then the command to install it is

sudo apt get install ucblogo

A gentle introduction to the Logo language can be found at the Logo foundation. You should bear in mind that, unlike languages such as C, there is no standard syntax for Logo and so the language varies from implementation to implementation. To get an idea of the number of implementations out there take a look at The Great Logo atlas.

This little investigation started out as a nostalgia trip for me but has ended up being a bit more than that. I thought Logo was a dead language from my past but it seems that it is still very much alive and well. It even has an active usenet group. When I was learning Logo at school we didn’t take it much further than the geometric pictures shown above which is a shame because it is clearly a very powerful language.

Since I already have to keep so many languages in my head for professional reasons, I doubt that I will use Logo for anything serious but will almost certainly be playing with it from time to time. Logo is fun and sometimes I forget that I got into programming in the first place because it can be fun.