Volume 1 Issue 1 - Summer 2001
|Clem Rutter, an ICT Teacher at Crown Woods in Greenwich, considers the value of Logo against such favourites as Pascal and Basic and sees a need for a range of tutorials to exploit its potential in secondary.|
When I picked up a previous journal and found a copy of MSWLogo attached to the front, my first reaction was to say, “at last someone is taking LOGO seriously- this time I really must master it.” In the early days of computing in schools, LOGO was there but we were too busy batching up cards or checking coding sheets for ‘O’s in line numbers- then there was CPM to learn. Then came the wave of hobby computers.
Ten years ago, a proportion of our pupils had learnt some rudimentary coding in Basic, and the problem was to minimise their bad habits and introduce rigour and structure into their programming generally by teaching Pascal. Now we must teach programming (control?) skills from scratch as computers don’t arrive with a built in programming language. So has LOGO’s time come? Can it replace Pascal at ‘A’ level? Has it other uses?
LOGO’s worst enemies have been its own turtle graphics, the ‘born again’ fervour of its child centred advocates and its inaccessibility to ‘Pascal’ and Fortran trained programmers.
A good spin doctor would describe LOGO as a dialect of Lisp (the artificial intelligence language) with a user friendly graphical front end. He would then explain that it has all the constructs needed to teach programming principles with the minimum of ‘syntax traps’. He would eulogise on the way that data structures can be taught, and the easy way that mathmos can tackle geometry and calculus. As MSWLogo is freeware- students can legally take a copy for their home machine.
What exactly is LOGO, UCBLogo and MSWLOGO?
Scheme and Logo are two dialects of Lisp, a language based on the processing of lists by using a composition of functions. In Logo everything is a procedure call. Procedural languages like Basic, C, and Pascal ultimately derive from Fortran, but Logo is a Lisp with Turtle graphics. Its creator Papert, studied with Piaget, and then worked at MIT.
There is no published standard. Logo has many dialects, some long dead and some extended. The version ACITT distributed was written by George Mills based on the work of Brian Harvey. Both Logos are free, so can be passed on to colleagues and students.
Brian Harvey wrote UCBLogo as a standard Logo that can be used on UNIX, Linux, DOS and Windows in DOS Mode. He is the acknowledged expert on Logo and has written the only serious textbook suitable for teachers of IT. Computer Science Logo Style. Three Volumes published by The MIT Press. I got a copy of Volume 1 for £24.40 from amazon.co.uk. There are details of all his books on Logo and Scheme on his website.
George Mills adapted UCB to take advantage of Windows dlls. It is not as pure as UCB but allows you to control the windows interface and some hardware features. There is provision for accessing dlls, midi sound and networking through TCP/IP can be invoked.
There are many Logo Tutorials on the Web. I started with Paul Dench
Jim Fuller is writing LOGO- working on control through the games port He has written a excellent formal tutorial.
Logo can be used at all levels. This tutorial will move too fast for some but addresses some of the problems of elementary robotics.
There is a wealth of logo ideas on the web, links can be found at:
The logo-l web newsgroup allows you to talk to all the people mentioned. To join send email to (email@example.com). Include "subscribe logo-l" in body of the message, with no other text.
Logo is an interpreted language. It is not case dependent. It is written in lines.
Each line is made up of functions. There are two types
commands (which do something but don’t return a value) like
operations ( which just return a value, its output) likesum, first or readlist.
A special subset of operations called predicates, that just output the word“true or “false. These are conventionally written with a final ‘p’- like emptyp, wordp, listp.
Functions can be primitives, or can be defined by the user.
Functions can take zero, one or more parameters.
Mathematics in Logo uses prefix notation, like:sum :x :y, product :x :y, difference :x
:y, quotient :x :y. Infix is also available.
There are three datatypes, the word, the list, the array.
A number is a special case of word.
There is no strong typing. The interpreter detects the datatype by context.
There are two important symbols:
The colon : - this means ‘the contents of’
This is an extremely useful symbol that keeps reminding students that a variable is really some ‘place’ in memory.
The quote ‘ - this means ‘the word is evaluated as itself’, or ‘its value after evaluation is the same as it was before’. This is important.
A number is a special case of self evaluation - it really could be written with a quote -2 is really “2
Assignmentin Pascal x:= y +3 becomes in Logo
make “x sum :y 3or make “x sum :y “3
make takes 2 parameters, the second of which here is sum. That takes two parameters and is a operation, thus the calculation is possible. “3 evaluates to 3, and :y takes the contents of the thing called y, these are summed giving a number. The effect of make is to place the result into the first parameter.
An alternative way of looking at this is that the second parameter is ‘passed by value’ while the first is ‘passed by address.’
Scoping Variables don’t have to be declared before use. Their scope is then global.
A variable may be declared local, when its scope is limited to that procedure and its subprocedures. This is dynamic scoping.
Discussing lists comes as a surprise to the Pascal programmer, who have managed quite well without them, however this opens many new possibilities. There seems to be few tutorials on this at any level- and none that can be plagiarised for school use. Arrays are also provided for the timid.
first, butfirst, last, butlast, member and item. Data is added using sentence fput and lput.
Operators exist to convert words into lists, and lists into arrays and back again.
This data type has the advantage over array in that it is infinitely expandable. Data is extracted using the operations
A list can be considered to be a queue with the operatorsqueue and dequeue, or a stack with the operations push and pop.
Recursion rather than iteration is the natural method to process lists. This is easy to do because of dynamic scoping.
Control Structure Commands
The standard Pascal controls are available, there is selection:
ifelse test [ do if true list ] [do if false list]
There are iteration commands:
while condition [instruction list]
until condition [instruction list ]
repeat number [instruction list]
Recursion is Logo’s preferred processing paradigm.
The standard commands arereadlist readword readchar with the normal input stream being the keyboard. In Unix tradition the input stream can be changed, so input can come from a disk file. Similarly, output can be redirected. The technique will be familiar to Pascal Programmers- using a sequence
MSWLogo allows input from COM ports and LPT ports and also ‘hardware‘ ports. MSWLogo also supports a windows interface thus I/O is available through this GUI- and keyboard and mouse events can trigger interrupts.
Logo instead of Pascal?
Logo is slow, it is not suitable for processing vast amount of data- but surely this isn’t the point at ‘A’ level. Speed is not an issue anymore – sometimes it is educationally more useful if you can watch your program cranking through a problem. The visual output allows this. It assists the student’s understanding that the computer is working sequentially through the instructions.
Logo scores on graphics, and MSW allows you to use the Windows dll. The crucial point for ‘A’ level teaching in Pascal is that students must master ‘pointers’ before they can do any useful data structure theory. This excludes all except the most committed. In Logo, Lists, stacks and queues are trivial. Trees are more fun. All are recursive in nature.
Our students can be ‘reluctant programmers’. Many take no pride in computer programming and here the superior graphics helps to retain interest - Pascal cannot offer that.
If you are that committed to Pascal, UCBLogo and MSWLogo include a rudimentary Pascal interpreter written in Logo as one of its examples.
Unfamiliar control structures
The Pascal programmer will be surprised by a series of list based control structures. The basic idea is that you have two lists
[ a list of commands ] [ many data items ]
each of the commands is applied in turn to each of the data items. There are several of these ‘template ‘commands with names likeMAP, APPLY, FILTER, FOREACH, REDUCE and CASCADE. They represent four flavours of template iteration, known as explicit-slot, named-procedure, named-slot (or Lambda) and procedure-text. This is a further step in programming that one can choose to ignore until time and curiosity become available.
The richness of MSW Logo
Yes, there is turtle graphics. While ten years ago youngsters were excited by drawing a simple line on the screen, their aspirations have changed. The turtle graphics can be used to demonstrate visually the more complex ideas such as iteration and recursion. Its weakness is that it sends out the message that- “I used that when I was eight—do you think I am a baby?”
This is not a problem if
none of them have heard of LOGO before.
the alternative to simple line drawings is doing simple sums like the roots of a quadratic or the sum of a series which really bores them.
in a life of change familiarity offers security, and a chance to succeed.
The expert can generate series of graphics in LOGO. Save them as bitmaps then combine them as an animated gif for the killer web page.
With MSWLogo students can draw on the screen modal and modeless windows, buttons, comboboxes and slidebars. The buttons can be programmed to invoke code. Such a GUI is essential in today's youngster’s minds. It allows the less gifted the chance of producing a professional looking front end. It allows students to trigger events- in a way not offered in Pascal. It frees vast amounts of practical time for deeper study- and leads in to Form design in Access.
A tune is essentially a list of notes, and MSW has a sound command. It also can use MIDI files. More potential for gaining student’s interest. As you invoke the frequency and time as parameters there is opportunity to investigate the physics of music. You can get multiple PCs singing in harmony.
There is I/O to files, keyboard, to the COM and LPT ports, and from the games port. There are TCP/IP networking functions. This allows control possibilities. All I personally need is a set of ready made robots, and an operating system that allows me personal control of my machine’s I/O ports.
MSW Logo is rich, it is freeware and MSWLogo can deliver. What’s missing seems to be simple tutorials explaining these things. We need tutorials to extend the gifted, we need tutorials for the average and tutorials for special needs. We need tutorials on all aspects of the National curriculum. We need tutorials written in a way that we as Fortran/Pascal trained teachers can understand.
A small demonstration program
;; An example-Hello World. This shows the time function, and how to remove
;; the first word. We also see how buttons and windows can be made. By pressing
;; the ‘*’ button, we get a demo of co-ordinates and the random function.
windowdelete "earth ;tidy up
to boldly.go ;Sets a location
pu setxy -250 + random 500 -150 + random 300 pd
rt random 360 ;sets the pointers angle
to galaxy :num ;Draws ‘n’ stars
repeat :num [ boldly.go star random 50 ] ;of random size
to star :size
repeat 5 [fd :size rt 144 ]
local "wnx make "wnx 100 local "wny make "wny 90
local "marx make "marx 5 local "mary make "mary 20
local "sizx make "sizx 10 local "sizy make "sizy 10 ;setting local variables
windowcreate "main "earth [Greeting the World] 0 0 :wnx :wny 
buttoncreate "earth "bm "* :marx+:sizx*4 :mary+:sizy*1 :sizx :sizy [galaxy 50]
buttoncreate "earth "bz "x :marx+:sizx*8 :mary+:sizy*5 :sizx :sizy [all.over]
staticcreate "earth "bw [Hello World] 25 50 50 25 ;using windows is easy
staticcreate "earth "bt bf time 25 5 50 25 ;time is a list of words
Make "startup [zzz]
Adding intelligence to the race track game
;; Here is the race track game - but the turtle is programmed to find its own
;; way round the track. It does so by using the pixel command to test whether
;; it is still on the red track (4 ) or has fallen off. This is not as easy as
;; it sounds!! In fact there are far better ways of doing this than this. The
;; challenge is to get it to work properly!
setpc 4 setpensize [ 20 20 ]
rt 60 fd 60 rt 40 fd 120
rt 100 fd 150 rt 90 fd 120
rt 65 fd 80
make "hue pixel
make "trail 0 setpc :trail
setpensize [ 2 2 ]
repeat 1000 [ walk.step ifelse :hue = pixel [ walk] [ walk.back ] ]
bk 1 fd 2
bk 5 rt 30 fd 5
pu fd 1 pd show pixel
Clem Rutter is an Elected Member of Medway Council and teaches ICT at Crown Woods School in Greenwich.
Volume 1 Issue 1 - Summer 2001