Teaching your kids how to write computer programs

by Marshall Brain

Quick Intro – If you are looking for a quick and easy way to teach your kid a “real programming language”, without downloading anything or buying anything, try these Python tutorials. Your kid will be writing and modifying code in just a few minutes.

Let’s say that you have children, and you would like to help them learn computer programming at a youngish age. As the father of four kids, I have tried to approach it from several different angles. What I would like to do here is collect some ideas for parents who are looking for different options.

Let’s start with a something important: Every kid is different. Some kids are reading and writing fluently years ahead of other kids. For them, learning to program is probably easier. Some kids have the basic analytical skills a lot earlier than others (Here’s a story about a 9-year-old writing full-blown iPhone apps). And so on. You try to expose your kids to programming and it may or may not “take” the first time, simply because of these differences. So you wait a few months and try again, or you might try a different approach. Understand that, the first time you try to introduce your kids to programming, your kids might not “get it” at all. And that’s OK.

The second thing to realize is that real analytical skills often don’t start appearing until age 11 or 12 or 13 in many kids, so expecting huge breakthroughs prior to that may be unrealistic.

That being said, there are lots of fun things you can try as early as five or six…

Games

Let’s start with a few games. Here are three games that my kids have particularly enjoyed. They teach basic problem solving ideas in different ways:

  • Magic Pen (wait a few seconds to see the word “play”, then click the word “Play”)
  • Fantastic Contraption
  • Auditorium (Drag the circle-with-arrow-in-it around. Enlarge or shrink the outer circle by dragging. Try to aim the stream at the bars. Once the bars fill, click anywhere to go to next level)

If you look around on the web you can find lots of “problem solving” games like these three.

Then there is this game, which actually does a very good job of teaching simple programming skills:

  • Light Bot (click the “Play” button and start with the basics)
LightBot

I love Light Bot. It will engage kids for a couple of hours, starting at age 7 or 8. Some of the puzzles in LightBot are too hard for kids. There are walkthroughs on YouTube that help.

Prefer games on a tablet or phone? Wired.com recently recommended a robot app here. See also this list.

LOGO

As soon as you try Light Bot it may remind you a little of LOGO – a language for younger kids. You can find out more about it on a page like this:

  • LOGO Programming (click on one of the programs on the right and watch it run, then modify)
  • LOGO Programming (has a tutorial for LOGO commands and exercises to try)

Or jump into Google. There is lots of stuff about LOGO on the Web.

Python for Kids

Logo is pretty limited. What if you want to teach your kids a “real” programming language? Python may be a good option to try because it is now fairly ubiquitous and it is easy to get started. These tutorials can get you going fast:

Python Turotials

Or type “Python for kids” into Google – there is lots of stuff out there.

Bigger efforts

Lego Mindstorms

One thing that one of my kids enjoyed quite a bit is Lego Mindstorms. This is a Lego robotics kit. I’ve seen kids as young as six or seven doing meaningful programs with it. It uses a graphical language that is pretty simple to understand. If you don’t mind blowing $200, then it is definitely worth a look. If you find that your kid really likes it, you might also look into FIRST Lego League (FLL teams build Mindstorms robots, work on presentations, etc.). One of my kids has been on an FLL team for several years and it has been great for him.

The good thing about Mindstorms is that it lets kids build some interesting stuff. The problem is that, after a month or two, you may find that you have come to the limits of what it can do. [Yes, there are adults on YouTube showing off some amazing, advanced stuff, but I suspect that these people are geniuses.]

A friend recommended this educational system for programming robot simulations. It is free:

RoboMind

Another big effort like this is Phrogram, formerly known as Kids Programming Language. KPL had the huge advantage that it was free and pretty amazing. It came with dozens of sample programs and could do both simple and complex things (for example, a really good pinball machine was one of the samples). But for some reason they killed KPL off and morphed it into Phrogram. Phrogram is $50, and I haven’t tried it, but assuming that it is a similar package it might be worth it.

Here is a free system from MIT called Scratch:

My kids played with this for a couple of days. See also this page.

If your kids would like to create games, here is one option to try:

GameMaker is a pretty sophisticated tool with a lot of options. There are tutorials to help you get started. I would not use this as a “first foray” perhaps, but it is something to consider for a second foray.

Also there is a free eBook on creating games with Python which states, “written to be understandable by kids as young as 10 to 12 years old, although it is great for anyone of any age who has never programmed before”:

A friend has suggested that this is a nice intro.

One other thing to try is:

The tagline is: “Codecademy is the easiest way to learn how to code. It’s interactive, fun, and you can do it with your friends.”

MIT App Inventor

This summer my twins (age 12) took a class using the MIT App Inventor. This is an impressive system for creating simple apps on Android devices. The twins were creating simple Android apps on the first day, and went on to create a bunch of apps themselves. They really enjoyed it!

MIT App Inventor

If you would like an introduction, you can find lots of introductory videos like these:

Making Web Sites

What if your kid wants to make web sites? This is a programming realm now. Here is one free, comprehensive educational experience I have seen:

Again, this is not for little kids, but definitely possible for teens with the knack. It covers a lot of ground: HTML, CSS, Ruby on rails, Javascript, etc. This could be a career path if your kid really enjoys this stuff – a lot of opportunities are available in the job market.

What about a simple web site, without any programming at all? I would recommend WordPress. You can get started with it here:

You can do some amazing things without any code. But it really helps if the kid is “technical” and likes putting things together.

Real programming – Stanford’s Java Class

My son (around age 13) started using Stanford’s free online Java class and he has gotten a lot out of it. The class includes YouTube lectures and class assignments that reinforce the concepts discussed in class. The programming environment used in the class is called Eclipse. Eclipse is a full-featured development tool with a great debugger and it is free too. This is the class my son took:

Introduction to Computer Science | Programming Methodology

See also:

CS106A: Programming Methodologies

Our son needed a little encouragement from his parents (i.e. deadlines) to get through the first assignments, but by the time be got to Programming Assignment #4 (writing the code for the game called “Breakout”) he was completely engaged and extended that basic game in a number of directions without any prompting from us. I feel like this class taught him the essence of being a “real” programmer.

Stanford has many classes to explore – click for list. Their offerings represent a valuable resource for anyone wanting to learn programming.

Once comfortable with Java, something like this might be interesting to try – a combination of Greenfoot and Java:

Real programming – C and C++ Programming

The C and C++ programming languages are two of the most widely used programming languages in the world. There are free compilers that are readily available and lots of tutorial information can be found for free. Here are two resources that can help get you started:

Google is your friend and can help you find tons of other stuff.

Learning to write iPhone and iPad apps

Writing apps for the iPhone and iPad is not for newbies, but it is definitely something that middle school and high school students can master if they have a knack for programming. And the audience for these apps is gigantic through the App Store that Apple operates. Here are the steps that you need to take if you want to get started:

Step 1 – Step 1 is to buy a Mac computer from Apple so that you can compile apps. The cheapest entry point is a Mac Mini at $600. A MacBook Pro is a laptop that costs about twice as much.

Step 2 – Once you own a Mac, go to the Mac App Store and download XCode. It is free. This package contains the development environment, the compiler, SDK and libraries, and a simulator so you can test your apps on simulated iPhones and iPads.

Step 3 – Apple offers a series of introductory tutorials:

Start Developing iOS Apps Today

Creating Your First iOS App – Hello, World

Creating Your Second iOS App – Storyboards

Your Third iOS App: iCloud

Step 4 – Take the Stanford class on app development: CS 193P iPhone Application Development. Here is the first lecture:

Step 5 – Once you develop your first app then it is time for Your First App Store Submission – You have to pay $99 to join the Apple Developers Program to take this step.

Google can help you to answer nearly any question or problem you run into as you are learning.

What about Android Apps?

After talking about Apple Apps, it is only fair to talk about the Android platform too. Here is the “official site”:

It is some pretty technical stuff. A teen with the knack should be able to approach it though. This page follows the same vein:

Google is your friend, again. Use phrases like “Getting started with android apps” and “How to write your first android app”. Find something that feels comfortable for your teen. Also consider the Standford option: CS193a Android Programming or:

Android Course Winter 2011 Lecture 01 – Welcome Demo

That will get stale as time passes, but it is a nice intro.

The BASIC Stamp (and see below for the Arduino)

BASIC Stamp

I have actually had a good bit of luck engaging my 10-year-old in programming using a device called a BASIC Stamp. So I would like to spend a little time here talking about it. It is not cheap, but it has three things going for it:

  1. It combines programming and simple electronics
  2. The programming tends to be very simple
  3. You can do real things with it, or at least things that seem realer (to my kids anyway) than Mindstorms.

We were first introduced to the BASIC Stamp when we found this kit at Radio Shack for $90:

What’s a Microcontroller BASIC Stamp Kit

You can also order it here:

BASIC Stamp Activity Kit

The big caveat is that you need to have a computer with a serial port to use it. If you do not have such a computer (most computers made since 2005 don’t have a serial port), then you need the USB version of the kit for $160:

BASIC Stamp Discovery Kit – Serial (With USB Adapter and Cable)

And if you are going to do that, I might suggest you consider this robot kit instead, because it is the same price:

Boe-Bot Robot Kit – USB Version

So, already, you can see that the BASIC Stamp is not simple or cheap. We’ve already had to worry about port types and which kit to get. And if that puts you off, so be it.

But we did buy the kit at Radio Shack, and we did have an older machine with a serial port, and we did get it set up and it did all work and… here is what was amazing about it. My kid could sit down with the book, by himself, and on his own he could wire up little circuits and write little pieces of code and get it all working. The programs and the electronics are easy enough that a 10-year-old can manage it. This is admittedly simple stuff, like wiring up a push button and having it make an LED blink, or making a servo motor turn or making sounds come out of a speaker. But the idea that my kid (who hates reading for the most part) could get this stuff working was impressive. And then he could think of extensions on his own. Trivial extensions, yes, like making two LEDs blink, but extensions.

The nice thing about this approach is that you can buy other pieces at Parallax.com and they are pretty easy to hook up. One of the first things we bought was a PIR module ($10), which is the kind of thing you use in a burglar alarm or an automatic light to sense a warm human body. We also bought a little text LCD panel ($25). And he built a device that could count people as they walked by. If you have a family of six people, how many times do they use the stairs in the house? How many times do they open the refrigerator? With this device you can find out. (The refrigerator was funny – it was opened something like 50 times a day!)

Next thing was a ultrasonic sensor ($30). With that and the LCD display you can build a little ultrasonic tape measure. They have a lot of little sensors like this that you can try. We’ve used the accelerometer, the thermometer, the RFID tag reader, etc.

His latest adventure is with the GPS module ($90) and the USB memory stick reader/writer ($35), which he used in a science fair project. With the USB memory stick thing, you can plug in a USB memory stick (AKA “thumb drive”) and read and write files. So you can create a text file and start dumping in data. Then you can hook up the GPS, let it gather data and save the data into the memory stick. With that you can create bread crumb trails everywhere you go. You can then plug the memory stick into your laptop’s USB port, load the data into a spreadsheet and do a scatter graph…GPS Scatter Plot

…or you can drop the data into Google maps as described here:

Mapping GPS Coordinates using Google Maps

As it turns out, the Parallax GPS is not the greatest. When we first hooked it up, it would never get a lock on the satellites. After an hour of probing on Google, we found out that you have to mount the GPS about 10 inches away from the Stamp (because of electrical noise generated by the Stamp). It would have been wonderful if this fact had been revealed in the Parallax documentation. But even after you do that, this device can have trouble getting a lock sometimes (ours doesn’t work at all in rainy weather, for example). It does work in the car if you put it on the dashboard, but not from the interior. [All of these problems eventually led us to a site called Sparkfun.com, which has a much better selection of GPS modules that are slightly less easy to use.]

It also led us looking for material on the web about the BASIC Stamp. There is a lot of it. For example, there are people building autopilots from BASIC Stamps:

You can find all kinds of stuff like that. Then you discover that there are many other platforms more advanced than the Stamp, like for example the Arduino, the Teensy, the Microchip PICkit (see also this book and this book), the Gumstix, etc.

The Arduino

Since this article was first written, the Arduino platform has really taken off and replaced the BASIC Stamp in the hearts and minds of hobbyists. There are so many different flavors of Arduino, so many different accessories, so many different kits, that it is now a very rich environment, and a lot of fun.

Here are some examples of different kits available:

The easiest way to get started with the Arduino is to buy one (for example, buy an Arduino Uno) and start programming. This article is a great introduction to getting the development environment downloaded to your machine and starting to program:

Arduino How To

The first time I tried it, it did not work. There were two settings (the type of Arduino and the com port) that I had to set, and the article provided guidance. We have purchased a number of accessories, including this touch screen, and have had a lot of fun with Arduinos.

The Raspberry Pi

Then there is the Raspberry Pi – a very small but complete computer that fits in your hand. You hook it up to a keyboard, mouse and monitor and turn it on. It boots up a version of Linux and you can start programming. It comes with Scratch (see above) and Python and can easily handle other stuff. It can also send signals to hardware like Stamps and Arduinos do. I own a Pi, its camera, a relay board, etc. My kids and I have played with it. But for some reason it never really caught on with them.

Conclusion

The point is, if you want to introduce your kids to programming, there are MANY different ways to do it. If you want to go down this road, Google is your friend. It is amazing how much stuff is out there. Just start looking, try different things with your kids, and see what works for you. It can be a lot of fun.

PS – Note to self: Open GPS Tracker, the BigAVR2



You may also enjoy this in-depth interview, “Marshall Brain on Singularity 1on1: We’re approaching humanity’s make or break period”:

On the coming Singularity and Artificial Intelligence:

A Conversation with Marshall Brain from MIRI on Vimeo.

The Official Site for Marshall Brain