I Want To Teach My Kid How to Program

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.

14 comments.

  1. Unity 3D, and if you really want to use python, Boo is a version of python, although C# is a better way to go IMO.

  2. I’d like to also recommend the “processing” environment:
    http://www.processing.org/
    http://processingjs.org/ ( a version hosted in javascript, no computer needed! )
    I like these because they are interpreted, but also high speed. And most importantly graphics are a first class citizen, so things can go far.

  3. And I’d like to recommend you take a look at GvR (http://gvr.sf.net), a simple programming language, based on Python, that was developed by students to teach students to program, with the intent to have them learn the concepts in GvR and then advance to Python, which has a similar syntax. Disclaimer: I’m one of the students who developed the initial couple versions of this about 9 years ago.

  4. Interesting. Python is a language that belongs on my list of “do not feed to children.” Both my children, now 9 and 7, have been using Haskell for about three years. They blow away many of my colleagues. I doubt this would be the case had they started with Python. Universities also reinforce this unfortunate mode of teaching.

  5. In addition to everything you’ve considered and the excellent suggestions, see Hackety Hack (ruby based, but it’s a simplified DSL): http://hackety-hack.com/

    Also take a look at RaphaelJS for browser-based animations (to supplement with your own game code). There are also a few game-related javascript libraries that you could google up. Good luck!

  6. I ‘started’ at 7 I think, and I’d do it again. I think reading, basic math, and a lot of patience are the only prerequisites you really need. I disagree with your stance and modding though. It’s IMO a great way to get into (game) programming. The knowledge you gain is definitely transferable, and more often than not, the sky is the limit. The big plus there is that you already have something done, and all you need to do it is to extend it. If you’d want to do anything comparable from scratch you’ll need years.

    I also think that javascript could be goodfor beginners. It’s quite easy and forgivable to learn, and you can get nice results quite quickly.

    And by the way, teaching monads to a 4 year old sounds like child abuse ;)

    Jonas

  7. Please look at http://github.com/jdf/processing.py for a version of Processing based on Python.

  8. My kids have enjoyed playing with Kojo (think of it as a post-functional Logo using scala). Definitely worth a look.

    http://www.kogics.net/sf:kojo

  9. You received some seemingly worthy objections, but this is one excellent piece of a blog post. I’m looking forward to enjoying the book.

  10. I usually use Ruby for teaching, because you can strip it down to something very simple. All that “idiomatic” Python/Ruby is just confusing to beginners. For example a for loop in Ruby can be as simple as:

    for i in 1..10
    print i
    end

    To do the same in Python you have to do some “range-magic”. And after someone has mastered the basics you can easily move on to more complex syntax.

  11. I’d like to try to teach my daughter to program–but I am not a programmer. Amazingly, a friend of mine pointed me to this blog! Many thanks!

  12. Kodu from Microsoft is a free download for PC and allows you to skip the typing altogether and it lets you create games. I have only used it a little, but plan on having my daughter give it a try this summer.

  13. Hey!
    Thanks so much. I have QQ: once my child has written a game in Python how can he share it with friends?

    Thanks!

  14. [...] my investigations, it seems there are 3 programming languages that are easiest for kids to start with; Python, Ruby [...]

Post a comment.

Switch to our mobile site