The Trick Of The Mind
Written by Mike James   
Monday, 29 November 2021
Article Index
The Trick Of The Mind
A First Language
Active and Dynamic
What Remains?

A Computer Language for Drawing – Logo

Now that we have introduced the basic idea of a command language for drawing, we can use it to give the reader some of the experience of what it is to program. The drawing technique we’ve just met is generally called Turtle Graphics and is contained within a bigger, more capable, language called Logo, which has the explicit purpose of teaching children to program – but adults can have fun too. It was invented by Seymour Papert, one of the early innovators of using computers in education. He put forward all sorts of good reasons why Turtle graphics could be used to improve thinking abilities. The main observation is that it forces the programmer to think in the turtle’s place. That is, when you say turn x degrees it isn’t you who turns through the given number of degrees but the turtle and you have to be able to think what effect this has on the turtle’s next move. It encourages you to think outside your body and to put yourself in the place of the turtle.

This is a key skill in programming and general algorithmic thought. You have to write instructions that apply not to your current state but to the current state of some other entity. This is the first step in computational thinking – the second is to project oneself into the entity's future and see what effect your instructions have had.

As Robert Burns put it:

O wad some Pow'r the giftie gie us
To see oursels as ithers see us!
It wad frae mony a blunder free us,
An' foolish notion

What airs in dress an' gait wad lea'e us,

An' ev'n devotion!

To see things from another’s point of view is key to programming, even when the “ither” is an inanimate object like a robot turtle or, indeed, a computer.

Without the ability to simulate the effect, in our mind’s eye, that our instructions are having, creating them and especially checking them would be near impossible. Logo and its turtle were invented to allow children to acquire this skill.

To make turtle graphics capable of doing more we need two additional commands,




If you imagine that the turtle has a pen which can be placed on the paper, pendown, or lifted off the paper, penup, you can see that you can start and stop drawings.

So with these additions, what does the following draw:

fd 100 
rt 90
fd 100
rt 90
fd 100
rt 90 
fd 100

If you find it hard to work out get a pen and follow the instructions. When you do work it out you have put yourself in the turtle’s position as it obeys the instructions.
You will find that it draws two parallel lines, i.e two opposing sides of a square:


From this small addition you can see that programming does get more difficult to follow as it gets more complex.

Notice that Turtle graphics is a real programming language and you can type in these simple programs and produce the results illustrated above. If you want to do this visit and navigate to the playground where you can enter your programs, see them run and learn more about Turtle graphics. You can also see some of the impressive graphics created using the language. It has to be admitted that to create anything impressive you need to extend the range of commands so that it becomes a full programming language and this is an idea we need to explore in more detail.


There is one more subtlety of our graphics language that could easily be overlooked. The commands that we are using are a little more sophisticated than a simple imperative STOP! They carry some information that varies each time the command is used. If you have a command like Fd100 then this is just a single “go forward 100 units” command. What do you do if you want to go forward 150 or any any other value?

One solution is to invent another command, Fd150, but this means you are going to invent a command for every distance you want to use.

Of course the answer is simple. Don't define the command to be Fd100 but define it to be:

Fd n

where n is any number you care to use that is reasonable. So now in our little language you can write Fd 150, Fd 300, and so on. We have a definition that supports an infinite set of possible commands.

This may seem very obvious to you, but don't underestimate it. We have now moved into allowing commands with a complex structure. Not just “Forward by 100” but “Forward by any amount I care to specify”. 

The n in the definition is a placeholder for a value and when you come to use the command you have to replace it by a value that completes the command. In most programming languages n is called a parameter and has to be replaced by a value. That is, Fd n is not a command that can be carried out, but a template for a family of commands like Fd 100.

In the same way, in place of Rt90 we can define:

Rt a

where a is the number of degrees to turn through.

Notice that the use of a or n in the definitions has no meaning in itself. We use a to suggest “angle” and n to suggest “number”, but any other letter of the alphabet or any recognizable squiggle would do the same job. It is a placeholder and when we read it we understand that it is be replaced by something appropriate that does mean something.

This is where our example language starts to get interesting. This idea of the use of meaningless placeholders to stand in for meaningful things is a characteristic of many types of thought. It is, for example, central to mathematics where x is the most used symbol to stand in for something. It is one of the reasons why mathematics is often regarded as strange and mysterious – because it contains statements about things that are only specified by placeholders. For example, in x+3=5, x is a placeholder for the unknown quantity that when you add 3 to it gives 5. Clearly x is a placeholder for 2 and in general mathematics is full of statements about quantities that are represented by placeholders.

Last Updated ( Monday, 29 November 2021 )