Logo

9 AM August 1, 2005

Looking for a way to introduce programming to my sons, I downloaded MSWLogo the other day. Gee it’s fun.

Logo was designed as a teaching language. Logo is centred around the turtle and the drawing area. You give simple commands to the turtle – forward 100 and right 90 – and wherever the turtle goes, it leaves a line. You can combine these commands into simple programs, and with just a few lines of code, can draw some neat patterns.

I settled on MSWLogo, on the strength of positive comments from pages I found by searching for logo programming on Google. MSWLogo has a drawing window, a command window and a text editor (screenshot). What more could a junior programmer want?

Fiddling with Logo on the way home reminded me of my first, tentative adventures with Basic on the TRS-80 pocket computer. Logo is responsive and interesting – you can “make it do stuff.”

Time for an example. Here is the turtle on a blank screen:

The turtle is kind of triangular. According to one Logo text, its name is Ernestine. The turtle’s pen is tied to its tail, right in the middle of its flat backside. Now, using the editor, we rattle off a quick program:

to square

repeat 4 [forward 50 right 90]

end

From the command prompt, we can now type ”square”, and sure enough:

The triangle is, of course, the turtle, back where it started, in the middle of the screen. Now we can use our square in another program:

to flower

repeat 8 [

square

right 45]

end

And here is what it looks like:

Not bad for a few lines of code. What I found most fun, though, was drawing fractals with recursion. This little routine draws a tree, splitting each branch in two.

to tree :size

forward :size

if (:size > 10) [

left 30

tree :size * 0.8

right 60

tree :size * 0.8

left 30

]

back :size

end

tree 30” gives:

More complex fractals can be drawn with not that much more code. I even had it drawing the dragon curve in eight lines of code.

MSWLogo comes with an impressive range of demos. There are some 3d graphics, a bunch of games, and a Pascal compiler, written in Logo, that converts Pascal to Logo and executes it.

I’m glad I gave Logo a whirl. It stretched me, All in all, I can heartily recommend Logo as a fun toy for programmers. Logo encourages a different kind of thinking, and gives a big payback for a small investment.

By alang | # | Comments (4)
(Posted to Software Development and javablogs)

Comments

At 16:03, 01 Aug 2005 Paul Moore wrote:

Python includes a "turtle" module, which implements turtle graphics in a Tkinter window. It's much the same type of graphical environment, but with Python as the language. I had some success introducing my 9-year old son to programming using it.

But regardless of language, turtle graphics are definitely a *great* interactive "fun" environment...

(#)
At 23:41, 01 Aug 2005 André Roberge wrote:

Given that you like Python, instead of using Logo, you might want to have a look at
http://gvr.sf.net (Python look-alike language)
and
http://rur-ple.sf.net (uses Python).

They are based on the original "Karel the Robot". Of course, I am a wee bit biased in which one to recommend ;-)

(#)
At 01:59, 02 Aug 2005 AndrewR wrote:

I think you should teach your kids programming the same way we learnt - by installing a Commodore 64 emulator and teaching them BASIC.

(#)
At 08:04, 07 Aug 2005 Andy Todd wrote:

And if you have http://pythoncard.sourceforge.net/ installed you can have an interactive turtle without having to resort to Tk/Tcl

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green