Update (2017/11/18): I strongly recommend Bryson Payne's Teach Your Kid to Code if you are a parent or teacher who wants to teach programming to young adults.

Computer programming is a practical skill that can be applied to many professions and hobbies besides software development. However, it can be intimidating to break into. This guide will help parents point their kids in the right direction to get started in programming. (And it is also useful for anyone to get into programming.)

The Gist

Kids as young as 9 (or even younger) can learn programming, it doesn't require math skills beyond basic arithmetic.

Making video games is the best way to learn programming and stay interested.

Python is one of the best programming languages to learn for a first language.

If your kid finds typing frustrating, then Scratch might be a better language to learn.

"Invent Your Own Computer Games with Python" is a free book that teaches programming to complete beginners in Python.

py2exe can help your kid share their programs with their friends.

When making your own games, computer version of board games or simple games of chance are a good starting point.

There is no "best" age to start programming; any age is fine. I'd recommend around 10 or 12 would be a good starting point, though I began teaching myself programming around 9. Perhaps before 8 would be "too young". Despite what you may think, programming does not require math skills beyond basic arithmetic. If your child is comfortable with addition, subtraction, and multiplication (maybe even division), then they will be fine. Programming is more about general problem solving and "recipe following" skills than mathematics.

Learning to program, like learning anything, is not about having a high IQ so much as being enthusiastic enough to practice and wanting to learn more. I think the best route to learning programming is by making video games.

Deciding on a Programming Language

Next, you should decide on a programming language to learn. The ones I recommend (which are all available on Windows, Mac, and Linux) are:

Python has a gentle learning curve, powerful capabilities, and lots of documentation. I recommend Python as a starting language the most.

Scratch was developed by MIT to teach kids programming with a graphical, snap-together Lego-like environment. They publish statistics of their audience by age (http://stats.scratch.mit.edu/community/usersbyage.html), which seems to peak around 13. Scratch is especially good if your kid doesn't have typing skills.

Ruby is similar in many respects to Python, however seems to have smaller community and documentation. I recommend Python over Ruby. However, if you want to learn Ruby, Chris Pine's "Learn to Program" is well-reviewed.

Programming languages I recommend you not start out with:

Java and C# are similar languages that have a heavy emphasis on Object Oriented Programming. While this is great for professinal software engineers, it's an additional level of complexity that beginners shouldn't have to deal with.

C and C++ are also widely used by software engineers but also has a steep learning curve. The amount of low-level programming it gives programmers access to is great for writing efficinet code, but not so great as a starting language.

Perl is a scripting language like Python and Ruby, however its syntax has many shortcuts aimed at expert programmers who want to make their code terse. As such, Perl code can quickly become incomprehensible to beginners looking at code examples. PHP is designed for making web applications, which adds several prerequisites that your kid would have to learn (such as HTML). Also, there are some arguable points against the language's design. (However, for web applications it does have a gentle learning curve.)

Visual Basic is made for quickly producing GUI applications for Windows. You cannot make applications for Linux or Mac with it. It is also more suited for business applications than games. Note that "Visual Basic" is not the same thing as "Basic" (though the languages are similar.)

Basic is dead. There are many different variants of Basic (such as QBasic, DarkBasic, BlitzBasic, SmallBasic, Basic-256, etc.) but each of these has poor documentation or a small community, which makes it harder to find resources to learn about them. And unlike Python, Basic is only a learning language, not a language that is actually used by software developers.

Pascal is even more dead than Basic.

HTML and Ajax are not programming languages, and anyone saying "HTML programming" or "programming in HTML" is confused. HTML is the text format that is used to design web pages. Ajax is a type of JavaScript programming to make web sites update the contents of their pages without refreshing the page. Neither of these teaches programming to a beginner.

TI-calculator programming is extremely limited. Skip it.

Game creation kits or game mods bypass much of the knowledge needed to learn in order to build games, but the range of games you can make with these kits is often limited. Also, skills developed in one game creation system usually aren't transferable to other systems, or even to programming in general.

Logo & Turtle were historically used to get kids into programming by drawing interesting pictures with the computer, but are out of date now. Scratch is the next generation form of Turtle and Logo.

Lego Mindstorms provides an interesting way to learn programming by making robots, however these kits are often expensive. However, Lego Mindstorms is not a bad introduction.

Downloading and Installing Python (and Pygame)

You can download Python from the download page on http://python.org. Or just click here to download Python 3.1 for Windows directly. After the download completes, you can double click the file to start the installer. The default settings are fine, so just keep clicking Next until the installation finishes.

Be sure to download a Python 3 version (such as 3.1) rather than a 2 version (such as 2.5, 2.6, or 2.7).

Python by itself only lets you make games that accept and display text. The Pygame library adds the ability to program games with graphics, sound, and animation. To install the Pygame library, download the appropriate package from http://pygame.org/download.shtml, or click here to download the Pygame library for Windows and Python 3.1 directly.

A Free Programming Book

If you are going down the path of game programming with Python, this blog features the free book "Invent Your Own Computer Games with Python" at http://inventwithpython.com. Unlike other books that just give a laundry list of programming concepts, "Invent with Python" gives the source code for several game projects and teaches the concepts from these games. It is a book designed for self-study.

To find the source code for more games, you can check out the Pygame website's list of games at http://pygame.org/tags/ or the Code Comments series on this blog.

Typing

An important thing to keep in mind when introducing programming to your kid is that programming is a very typing-intensive hobby. If your child does not know how to type or has less than ideal motor coordination, they may get frustrated with programming. Even the slightest typo in a program can cause errors that can be hard to debug.

One option is to try Scratch, which relies more on mouse movement and snapping together "code blocks" rather than simply typing.

If you are using "Invent with Python", then the source code for the programs can be downloaded instead of typing them in. However, typing in source code is often the best way to learn programming. When your kid starts writing their own programs, they will need to type them in, so typing in the source code for these pre-made games gives a feel for what it is like to code.

However, your child may have typos in their code. The "Invent with Python" website has an online diff tool where your kid can copy and paste their code to find any differences between their program and the program in the book.

Graphics vs. No Graphics

Many people feel that kids will only be interested in programming if their games have fantastic graphics. I disagree that text-only programs are necessarily boring. They may be visually simple (and also easier to understand as well), but text games can also be engaging. (I go into detail on this topic in the blog post, Attitudes on Programming for Kids: "They Need Blood Exploding Onto Their Faces Just to Keep Them From Yawning".) "Invent with Python" starts with text games and moves on to graphical games later on.

If your kid wants to make games with graphics, it may be easier to download images from the Internet rather than use a drawing program to create them from scratch.

Having Your Kid Make Their Own Games

Encourage your kid to write out the design on paper first. It is a lot easier to make changes to a quick sketch and notes on paper than it is to code that you've already written. If your child is looking for ideas for games to make, computer versions of board games are a good start. Simple games of chance and probability are good as well.

It probably isn't a good idea to try to make graphic-intensive games, since developing all the artwork (or at least downloading images online) could be too large of a task.

You can convert Python scripts into executable programs with a Python library called py2exe. This way, your kid can share their games with any of their friends who have a Windows computer (they won't need Python installed on their machines.) Instructions for using py2exe can be found in Appendix C of the "Invent with Python" book.

Aside from the "Invent with Python" book, you can find more information online. The python.org website has a list of tutorials that are appropriate for complete beginners. The Pygame website has a similar list for Pygame tutorials.