Programming is a creative activity that any kid can engage in. Your child might not care about writing data processing algorithms, but they might enjoy creating games, programming music, designing websites, or just playing around with code.
By Al Sweigart
I've written several books to teach beginners of all ages how to code, and I know from experience that you don't need to consider yourself a techie or "good at math" to learn. In fact, kids often can learn to program faster than adults precisely because they don't know how "difficult" coding is supposed to be.
1. Use Scratch for younger kids, Python for older kids.
MIT's Scratch is a free programming tool designed for kids that runs in any modern Web browser. Anyone can run it at https://scratch.mit.edu. Its visual style was influenced by the Logo program, a staple of programming classes for children of the '80s and '90s. But Scratch is much more than yet another Logo knockoff.
Kids between the ages of 8 and 13 will benefit from Scratch's simple graphical interface. Scratch's drag-and-drop code blocks snap together. Pieces of code that don't make computational sense won't fit together, making syntax errors literally impossible. Scratch is great for younger kids who haven't developed typing skills.
2. Show source code for actual programs. Don't just talk concepts at them.
Despite its intellectual reputation, programming is a hands-on skill that requires practice, more than just reading books. Python's interactive shell encourages experimentation to find out what instructions do.
If you are tutoring your kids directly, writing code goes a long way compared to just talking concepts at them. Even after learning about variables, loops, and functions, sitting in front of a blank editor and starting a new program is intimidating. Sit with them and describe the code they should write line by line.
Or, if you are using online resources to share with your child, look for the source code to small games. Programs with less than a couple hundred lines of code work best.
The Scratch website automatically shares the source for all projects on its website. Encourage your kid to make modifications to the code and see how they change the final program.
3. Games are fun programming projects.
Programming video games is a common starting point for many young coders. Angry Birds, Minecraft, Flappy Bird, Five Nights at Freddy's, and other games are prime sources of inspiration. I've written a free book, Invent Your Own Computer Games with Python, which demonstrates coding concepts with the complete source code for several simple game projects (Tic Tac Toe, Hangman, etc.).
Be warned that games your kids love might not make great programming projects when they're just starting out. Many games require teams of developers, artists, and designers to put together. Games that require a lot of level-design and artwork can overwhelm beginners. It's much more satisfying to complete a simple game, than to start and never finishing a massive project.
4. Keep your hands off the keyboard and mouse.
Sharing knowledge is exciting. Showing someone what you know about programming is great. But coding is a skill that is learned with hands-on practice, so let the kids drive. Avoid jumping in to type on the keyboard when working with kids, even temporarily. If they have to click on a menu or button, point to the screen with your finger instead of taking the mouse and clicking it yourself. Whenever there is code to be typed, have them type it. It may be faster if you did it yourself, but your pupil needs the practice more than you.
5. If teaching a class, give each kid their own computer.
If you are teaching a group, try to give each student their own computer. Like playing a musical instrument, programming is a skill that is learned with hands-on practice rather than watching someone else.
The Raspberry Pi is a cheap, bare-bones PC that that runs about US$ 70 for a starter kit. Although adding a new keyboard, mouse, and monitor raises the total price to be comparable with a cheap laptop. Avoid Chromebooks, iPads, and tablets because; getting Python to run on them is difficult.
If you need to set up a computer lab for an afterschool club on a budget, the Raspberry Pi would allow you to make use of spare keyboards and monitors. (See the Raspberry Pi Foundation site and Ben Nuttall's monthly Opensource.com Raspberry Pi column for free resources.) Otherwise, I recommend the cheap laptop approach, especially if you don't have a dedicated space and need to store the computers after class. Laptops have fewer cables to deal with and store easier.
If individual computers aren't possible, kids can pair up and take turns. Remember Tip #4: Teach them from the start to ask their partner for the keyboard and mouse instead of just grabbing them away.
Some kids may be boastful and eager to dominate the machine, and less-confident kids will gladly let them have it. Have one kid be A and the other B. At points during the lesson, explicitly tell the group to switch seats so that A (or B) is in front of the keyboard and mouse equally.
6. Skip the computer science.
If you are a software developer, you might be eager to share your technical arcana. Explaining recursive flood fill algorithms or practicing problems from Project Euler (a great practice problem site for those who want to sharpen their coding skills) is a lot of fun. Being dumped in the deep end is not so fun on the learner's end. Some topics you'll want to hold off on at the start:
- Object-oriented programming
- Design patterns
- Data structures besides lists/arrays and dictionaries/hash maps (linked-lists, binary trees, etc)
- Networking protocols (beyond simple HTTP requests)
- SQL databases, or other Domain-Specific Languages
A good rule of thumb: If it's the sort of question that would appear in an interview at Google, skipping it might be better. When starting, covering a wide range of topics is better than going deep into technical details. Let your kids find their own passion. Once your child samples what the programming world has to offer, they'll be excited to explore the parts they like.