Teaching Programing Skills to Children with Logo

As a parent of three young boys, I often think about what it's going to take to be competitive in the job market of the future. Obviously, they'll need solid reading, writing, math and science skills, with history, literature and art thrown in to make them well-rounded. Being a computer nerd myself, I recognize the value of even basic computer skills.

Workers of the future will need to be able to use a word processor and spreadsheet, and they'll need to be able to send and receive e-mail. Those skills are so basic, they probably just barely will qualify people for a decent job. What will separate job seekers from the competition will be basic programming ability and the thinking processes that go with it. Although I don't advocate trying to teach your five-year old to program in C or Java, I do think you should start early. The Logo programming language is a wonderful way to introduce young kids to the art, and science, of programming.

For those of you who aren't familiar with Logo, essentially, it's about giving programming instructions to a frog, who then executes those instructions. The frog understands basic commands, such as “forward”, “backward”, “turnleft” and so on. This wonderfully intelligent and obedient frog also happens to be carrying a magic marker that he can use to trace out his path as he moves about on the computer screen. By sending the appropriate commands to the frog, you can cause him to trace out geometric shapes. For the parent or teacher, it's nice to know that the Logo programming language is easy to learn. I learned it in about 30 minutes, and I was fighting the flu. After all, it's simple enough for a frog, right?

Most of the Logo programming commands are pretty self-explanatory. The “forward” command takes one parameter, the number of pixels to move forward. The “turnleft” command also takes one parameter, the number of degrees to turn. The “go” command takes two parameters, X and Y, that describe a location on the screen where the frog should go. The “pendown” command tells the frog to put his pen against the ground so that it traces his path as he moves. Conversely, the “penup” command causes him to lift his pen so that he can move without leaving a trace. Amazingly, this pen also can change its width and color with the “penwidth” and “pencolor” commands.

The “clear” command erases all of the traces left by the frog, but it leaves the frog wherever he is. The “reset” command clears the screen and puts the frog back at the center. Most Logo programs will start with a “reset” command, unless part of the program entails being able to start from an unknown state.

This frog also understands math. He can add, subtract, multiply and divide. And, he apparently is well educated, as he knows the number pi and trigonometrical functions like sin, cos, tan, arcsin, arccos, arctan and the functions sqrt and exp. Of course, he also understands the concept of a variable to which your kid's program can assign values for later use.

Logo also supports program loops and branches. The if statement takes a (possibly compound) boolean expression and executes a bracketed block of code if the expression evaluates to true or an optional alternative block otherwise. Essentially, it looks like:

 
if <expression>
{ block } else { block }

There also is a while loop, a repeat loop (which simply loops a given number of times) and a for loop (which looks a lot like the for loop in BASIC).

For this article, I'm using KTurtle, which comes with the KDE environment. KTurtle essentially is an IDE that has a programming window, an execution window, an errors window and a debugger. You even can control the speed at which the frog executes your instructions. I'm sure there are other implementations available besides KTurtle. Let's take a look at a simple example so you can get a feel for what the language looks like.

reset
forward 30
turnleft 90
forward 30
turnleft 90
forward 30
turnleft 90
forward 30

This little program almost doesn't warrant an explanation. It simply clears the screen and draws a box with sides 30 pixels long.

Let's do a more complex example that shows of some of the frog's abilities.

$sides = 100
reset
$dotted = 1
repeat $sides {
	if ($dotted == 1) {
		pendown
		$red = random 0,255
		$blue = random 0,255
		$green = random 0,255
		pencolor $red,$blue,$green
		$dotted = 0
	} else {
		penup
		$dotted = 1
	}
	forward 5
	turnleft 360/$sides
}

This little gem simulates drawing a circle by drawing a 100-sided figure using dotted, multicolored lines. Actually, there's a bug in the program that becomes obvious when you change the number of sides to values less than about 20.

Fixing the bug in the previous program is a nice way to introduce one final feature of the Logo programming language: structured programming. Logo allows you to create your own commands, or subroutines, using the “learn” command. For example:

learn dottedline $n {
	$dotted = 1
	repeat $n {
		if ($dotted == 1) {
			penup
			$dotted = 0
		} else {
			pendown
			$dotted = 1
		}
	forward 2
	}
}

This snippet of code enables our frog to execute a new command called dottedline. Now our program looks like this:

$sides = 20
learn dottedline $n {
	$dotted = 1
	repeat $n {
		if ($dotted == 1) {
			penup
			$dotted = 0
		} else {
			pendown
			$dotted = 1
		}
		forward 2
	}
}


reset

repeat $sides {
	$red = random 0,255
	$blue = random 0,255
	$green = random 0,255
	pencolor $red,$blue,$green

	dottedline 6

	turnleft 360/$sides
}

And, if we run this program, we see a a 20-sided “circle” made with multicolor dotted lines. This program also behaves properly when sides=3, where the previous program did not. There's still the matter of scaling the “circle” as the number of sides gets larger, but that's beyond the scope of this article.

As you can see, Logo is a fairly simple, yet complete, language. The examples I've presented later in this article are probably a bit advanced for most young programmers; however, older programmers should be able to follow and understand this level of program logic. At this point, they should move on to a more advanced language. In the meantime, your younger students can learn to use commands to draw geometric shapes and pictures.

As a parent or teacher, I'd recommend starting by having students give the frog basic commands so they become familiar with the results. Then, as the students become more sophisticated, provide them with increasingly more complex geometric shapes and have them write a program to mimic that shape. If this is as far as you go, think about what you will have accomplished. Your students will have acquired mouse/keyboard skills, geometric/spacial thinking ability and rudimentary programming experience, and they probably will have a few giggles in the process. As long as you guide them along to keep them from getting “stuck” and frustrated, they'll do just fine.

As an introduction to structured programming, I'd present them with a working program like this:

learn box $count{
	repeat $count {
		turnleft 360/$count
		forward 20*5/$count
	}
}

reset

repeat 20 {
	box 5 
	turnleft random 1,360
	penup
	forward 50
	pendown
}

Let the students identify all the “tunables” in this program, change them one by one and observe the results.

As you can see, Logo is an easy language for an instructor to pick up, and yet, it's still very approachable for very young students. There's probably not much demand for Logo programmers in the job market, and I'm not trying to imply that my sons will grow up to be programmers, but basic computer and programming skills will give them many choices that they otherwise might not have, and the Logo programming language is a good first stepping stone.

______________________

Mike Diehl is a freelance Computer Nerd specializing in Linux administration, programing, and VoIP. Mike lives in Albuquerque, NM. with his wife and 3 sons. He can be reached at mdiehl@diehlnet.com

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

etoys

robi.y's picture

olpc project has etoys that contains logo.
pardon here but I use with my child the new small basic which also contains a turtle

Scratch is actually a better way to learn for youngsters

Bernie's picture

Scratch is better for teaching programming.
They even have a LOGO emulator: http://scratch.mit.edu/projects/cadams/56510

And with the Scratch sensor Board you can interact with the physical world from a scratch program.
http://scratch.wik.is/Support/Sensor_Boards

Cheers.

I remember!!!!

Anonymous's picture

I used it in my school when I was 12, I think!
The program which we were using was called WinLogo (and worked in DOS), and it was translated to our mother language, catalan.

A good way to start, but we used it basically to draw.

More than a means to teach programming

osod's picture

Great to see a Logo article 'in the wild'. Logo has many qualities that make it an excellent tool for learning entry-level programming: Extremely simple syntax (ie a shallow learning curve); a few core routines that make the language really useful; an extensive 'vocabulary' that can be learned as needed over time by neo programmers; simple graphics and text primitives; and powerful list processing and recursion. But learning programming is only one application: Logo is still among the best computer environments for working on mathematics and language structures with kids. Since the language has a 32 year history, there is a wealth of printed and online resources for the interested. Good Logoing!

hi

Anonymous's picture

Plz can u let me knw how to start LOGO programming that is where to write the commands... :)
I dont knw how to reach the LOGO promt...... plz help...!

Without Logo, I wouldn't be a programmer today.

John Rockefeller's picture

Our small computer lab in my public school library had 286 PS/2 computers loaded with Miser's House and Logo. When I was in grade 7 I got my first taste of computer programming through Logo. Haven't looked back since. I love it. Thanks, Logo!

Turtle!

augmentedfourth's picture

The "cursor" character has been both a frog and a turtle, probably in different implementations of the language. When I learned to play with Logo on an Apple IIe when I was a kid, it was a turtle.

EDIT: whoops, this was supposed to be a reply to "A N Mouse", below.

Lego Mindstorms is probably even better

FlorinAndrei's picture

The Lego Mindstorms brick: It's an ARM processor, it comes with a bunch of sensors and actuators. You can program it with a variety of languages, starting from a very simple visual drag-and-drop "logic scheme" thing, to C++ and whatnot. And on top of that the device actually does something in the real world. It's not just staring at a computer screen all day long, you can actually make robots and program them. Might be more suitable for teaching smaller children.

After a certain age, of course, it doesn't matter anymore and you can teach programming in an abstract way.

Logo

carrie's picture

This sounds very intersting to me. What is the recommended age to start with Logo?

Frog?

A N Mouse's picture

Why would the package be called KTurtle? Perhaps because in Logo the thing that does the drawing isn't a frog, which wouldn't be able to draw lines very smoothly...

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState