Both Leon Bambrick and Jeff Atwood have posted about LOGO recently, which reminded me to talk about Scratch. It's a FREE program from MIT that's aimed at teaching kids (or anyone else, I suppose) the basics of programming. More specifically, it gets them thinking about things like logic, flow control, and handling variables.
As a developer, I suppose it's natural to want to teach my daughters something about what I do for a living. (Note: I leave out the part about how moving into management mostly means sitting in meetings and spending more time in Outlook and Excel than in an IDE). But I do want them to grow up with strong problem-solving skills, so I've often gone out in search of good ways to teach programming concepts at a kids level. There are a number of initiatives out there, but Scratch is the one that has really taken hold for us. I've found it to be the best by far, even better than commercial products out there intended for the same purpose.
The free Scratch application is basically a workbench for creating programs using a drag-and-drop interface. You have a stage, which can be scripted to do things like clear itself, paint its background, and so on. On the stage, you drop sprites, which can be any sort of object. By default, your first object is a cartoon cat, but you can use any sort of photo, clip art, or pick from a library that is included.
For your stage and each of your objects, you have a script (or several) that can be run. This is where the genius comes in -- the script is built entirely by dragging and dropping blocks into place. No need to remember syntax or type in commands. You're essentially building a flow chart with these blocks and your "program" is executed from the first block (at the top) to the last (at the bottom). The blocks snap together as you drop them and there are good visual cues as you drag them around when and where they'll snap. If your program has multiple characters with their own script, all of those scripts run in parallel... and a single character can have multiple scripts (to support for example, moving around the stage while also waiting for some external input). The bottom screenshot gives a good example of parallel scripts.
The available blocks are grouped into categories, such as Motion, Control, Looks, Sound, Sensing, Numbers, and Pen. Each category has numerous blocks that let you control how your sprite moves, makes noise, interacts with other sprites, calculates, stores/retrieves variables, and uses its "pen". As with LOGO, the pen is the primary way of seeing what your sprite has done. You control the pen by putting it down, lifting it up, setting its color, size, and so on.
The "Control" group is where you can really do creating things as this is where flow control blocks are located. There are blocks to wait for input, "container" blocks that let you repeat other sets of blocks forever, a certain number of times, or until a condition is met. There are also If/If Else blocks and blocks to pause the script for a period of time.
The environment is very easy to work with and encourages experimentation. The left side is where the groups of blocks are stored, the middle is where you drag and drop your blocks, and the right side shows the sprites in your program and the stage where everything happens. It also has a "presentation mode" so the user can make their program run full-screen and show off to Mom and Dad.
I introduced my daughter to Scratch several weeks ago and it's now one of her favorite things to do on the computer. Given that she just received an OLPC, I'm glad to learn that there's an effort underway to build an OLPC compatible version of Scratch.
Initially, Scratch is great for use as an electronic Spirograph set. Kids can experiment by trying different things and take a "let's see what happens" approach to learning. The simple program to the right is what created the shape at the top of this post. Clicking on any of those numbers lets you change its value and it's easy to move the blocks around or add new blocks. You can see in this example that the orange flow-control blocks serve as containers for other blocks and that they can also be nested.
One of the first things kids learn, just as anyone else learning programming does, is that you have to be very explicit in your instructions. For example, without the "Clear" instruction in there, the stage would still have the previous shape and it'd be hard to see what your program is doing. Without telling the sprite where to start (0,0), the program would pick up wherever the sprite currently sites which is likely not what you want.
Scratch also comes with many sample programs that show you just how flexible it is. Games are fairly easy to program because of Scratch's support for input handling (detecting keypresses or mouse activity) and its support for collision detection. A good example is a little racing game that features a ball you have to "drive" around a race course. The arrow keys control the ball's direction and it speeds up the longer you hold them down.
However, if your ball goes off the race course and ends up in the grass (the program has an If block to see if the sprite is touching the color green), then your speed begins to slow down significantly. The program for it (visible by clicking the screenshot to the left) is surprisingly simple and it's a fun one for kids to experiment with because they can control which keys get used, how quickly the ball moves, and what the consequences are for going off-course.
I've tried out a number of different environments for kids to create things in the computer and Scratch is easily the best of the lot. It's a commercial quality piece of software that installs quickly and works very well. The folks at MIT have also created an online community of sorts where users can share their Scratch creations. The web site also has lots of videos, reference materials, and a PDF Getting Started guide that's very kid-friendly.
(Note: I just noticed that they've released a version 1.2 maintenance update in the last couple of weeks. It looks like they've added some advanced blocks, fixed a few things, and created a more detailed PDF reference guide. I'll be upgrading shortly, but the screenshots above were created with 1.1).
If there's a kid in your life that enjoys tinkering on the computer, introduce them to Scratch. Heck, introduce yourself to Scratch... I apologize in advance for the hours you're about to lose.