Tuesday, September 4, 2012

Logo turtle graphics

I remember fondly going to the university with my dad, as a toddler first, and as a young boy later. Pretty quickly, I was able to gain access to the computer lab, where they had the Apple ][. Later they would get the ][+, //e etc.

Anyway, there, I could request a disk with a wonderful program called Logo turtle graphics. That was  my first real exposure to programming. You controlled a little triangle (the turtle), pen up / down to draw or move without drawing, back, forward, left, right (rotations), etc. There was even the possibility of loops, functions etc. You can learn more about Logo here Logo Foundation

The Raspberry Pi Raspbian operating system comes with Python, and as such, with Turtle.

In logo, I remember writing something like this:

repeat 10 [ circle 50 forward 60 right 36 ]

With python, the last 4 lines are equivalent:

$ python
>>> from turtle import *
>>> up()
>>> back(200)
>>> left(90)
>>> down()

>>> for x in range(10):
...    circle(50)
...    forward(60)
...    right(36)

The result?

As a side note, I took the snapshot from my OpenIndiana desktop. I accessed the Raspberry Pi using the command:

ssh -X pi@rasp01

This allows a tuneling of X Windows, so when I start python, import turtle and start drawing, it is drawing using tkinter using the OpenIndiana desktop X server to render the above window.

In conclusion

I do owe my > 30 years in programming and the mastering of various languages such as assembler, Basic, C, C++, Pascal, Java, Python, etc to my first exposure to programming at a young age. It is crucial that the youth of today similarly get exposed to more than how to use Office or Photoshop. They need to learn how to program and how to tinker. And the Raspberry Pi provides that ticket into that world.

No comments: