In the beginning
In the beginning, there was a turtle. Yes, a turtle. No buttons, green flag, or sprites. Just a turtle.
Today, children learn to code using a block language like Scratch. They drag and drop puzzle pieces of code (individual commands) to create a program. Cartoon characters (called sprites) draw squares, polygons, circles, whatever your code tells them to do.
Turtle graphics, as this type of drawing is called, began in 1967 with a programming language called Logo. The language was created by Seymour Papert. The name Logo is derived from the Greek word logos which means word or thought. You can learn more about Logo from this Wikipedia article. Scratch is a descendant of Logo.
So, let's learn a bit about Logo by drawing a square. There are many online Logo environments. I like the appropriately titled, Logo Interpreter.
Today, children learn to code using a block language like Scratch. They drag and drop puzzle pieces of code (individual commands) to create a program. Cartoon characters (called sprites) draw squares, polygons, circles, whatever your code tells them to do.
Turtle graphics, as this type of drawing is called, began in 1967 with a programming language called Logo. The language was created by Seymour Papert. The name Logo is derived from the Greek word logos which means word or thought. You can learn more about Logo from this Wikipedia article. Scratch is a descendant of Logo.
So, let's learn a bit about Logo by drawing a square. There are many online Logo environments. I like the appropriately titled, Logo Interpreter.
Drawing a square
Logo is a text-based language. To draw a square, you use a few Logo commands.
Command |
What it does |
pendown |
tells the Logo turtle to place it’s pen down so when it moves, it draws a line. |
forward |
tells the Logo turtle to move a specified number of steps. |
right |
tells the Logo turtle to turn right a specified number of degrees. |
repeat |
tells the Logo turtle to repeat a command or commands a specified amount of times. |
So, we have our commands. Drawing a square is a useful endeavor and we might want to do it more than once. So, let’s write a program so we can just run the program whenever we need to draw a square.
Logo programs begin with the word to. Makes sense. You write a program to do something.
So, what do we want to do?
to drawSquare
Then, we add the commands to draw the square.
pendown
repeat 4 [forward 100 right 90]
Logo programs end with the word end.
to drawSquare
pendown
repeat 4 [forward 100 right 90]
end
To run our program, we type the word, the name of our program, drawSquare, and press the return key.
For comparison, here's the same program in Scratch.