My first introduction to programming was back in 2005 when I was in grade 5. We were introduced to this new course in our school curriculum called Computer Science. The only useful aspect of that course that I still remember is the Turtle Graphics program. It uses a very unpopular programming language called Logo. The basic idea is that you have a canvas and a turtle sitting on it. You can enter commands to move the title, and as the turtle moves, it acts like a pen and draws on the canvas. Simple enough? As a kid, this really helped me lay down solid foundations for understanding computer programming. I think anyone who is new to programming should give it a try because even if you are not a kid anymore, it can be extremely fun.
To get started, you do not need to install any software, just head over to this online Logo Interpreter and you’re good to go. What you see is exactly as described before, a white empty canvas with a turtle and a command box below to write your code along with the run button. To understand the basic syntax, let’s draw a square by typing the following code and pressing the run button.
CS ; clear screen ; first we get to the top left corner of the square (100 by 100 units) without drawing PU ; pen up FD 50 ; forward 50 units LT 90 ; rotate left (anticlockwise) by 90 degrees FD 50 ; now we start drawing each 100 unit side one by one PD ; pen down RT 180 ; rotate right (clockwise) by 180 degrees FD 100 RT 90 FD 100 RT 90 FD 100 RT 90 FD 100 ; return turtle back to center PU HOME
As you will see, the end result is that the turtle is back at the centre with a square around it. You can type one command at a time to see what each step does at a time. The actual scope of the Logo language is much higher than actually drawing simple shapes. The language allows numerous programming techniques to draw complex art. Here is an example code, just copy the code and watch as the turtle draws a beautiful tree.
; tree procedure (function) with input size TO tree :size IF :size < 5 [FD :size BK :size stop] FD :size/3 LT 30 tree :size*2/3 RT 30 FD :size/6 RT 25 tree :size/2 LT 25 FD :size/3 RT 25 tree :size/2 LT 25 FD :size/6 BK :size END CS ; clear screen tree 150 ; draw a tree of size 150
This is still a very simple program as you can see just by the size of it, but the result is spectacular for the effort. I am not going to explain how it works, but here is a hint: inside the tree procedure, there are calls to new tree procedures with different sizes. This is known as recursion, and is a very fundamental concept of many programming languages. Try to think of a reason for the end to recursion when the tree in complete.
If you would like to delve further into the Logo programming language, the Logo Interpreter website has a few example (one of which is the tree procedure), and a reference page explaining all the available commands. To get a basic understanding if you are completely new to programming, refer to this tutorial.