Teaching My Daughter To Code

First party of a journey of writing a Doctor Who video game in Java with my 9-year-old daughter.

[Update: part II, part III and part IV of this story are available now.]
[Update 2: Belorussian translation available now, provided by Webhostinggeeks.]
[Update 3: A translation in Punjabi is now available – thanks to the team at Bydiscountcodes.]

Yesterday, my daughter Sophie asked me to show her how to write a computer game. She is nine. (Well, only a few weeks away from being ten – at this age, a year still matters.) She has never written any code before. Now, there’s a challenge, if I ever saw one.

I am a computer scientist, and one of our projects is Greenfoot – a programming environment designed to teach kids (and older students) to code with Java. So far, that has all been part of my research work. Research into programming education, tool design, etc. I have used Greenfoot with kids (mostly about 15 years old), but more often I do presentations and workshops for teachers.

I have often wondered how low in age you could take Greenfoot. It’s Java, after all, not Logo. 15-year-olds clearly works. But 10 year olds? We don’t know.

So I told Sophie that we’d start making a game tomorrow. That was yesterday. So today was the day. Afterwards, I thought it might be interesting to try to record the process we’re going through — see what happens.

So here is my (hopefully continuing) diary of coding with my daughter… (Our results, live demo and source code, are at the bottom.)


Over the last few days, Sophie had been playing Midnight Mansion, a platform/side scroller game. Here’s a screenshot. This is the kind of thing she had in mind when she, in the evening over dinner, asked me whether we could make a game. So I suggested that first she would need an idea for a setting for the game.

Now, Sophie is a big fan of Dr Who, a long running (and when I say “long-running”, I really mean long-running: the series started 45 years ago!) sci-fi series of the BBC in the UK. If you don’t know it – don’t worry. Suffice to say: The hero is “The Doctor”, who travels through space and time and has various adventures. I’ll might get back to the details later, if we ever get around to making something happen in this game.
So, Sophie decided she wants to make a Doctor Who game. Now, here’s a very important point. If you ever want to teach your own kid (or any kid) to code, this is really crucial: find something they really want to do. Let them decide the story, choose something they like. They take ownership, and the roles are set. It is not you telling them to do something, it is them who want to do something, and you’re just helping them along. If you manage to get them into the situation where they have an idea, and they really want to do it, you’re half way there.

This morning when I got up and sat at breakfast (I’m always the last to get up on weekends in our house, so everyone else was finished already), Sophie was there bugging me to get started. So after breakfast, that’s what we did.

We took a bit more than an hour. (I hadn’t thought of writing this down beforehand, so I didn’t really check the time. It might have been a bit longer, but less than 90 minutes.)

First, we started up Greenfoot. Since I had it already installed, that was easy. We started by creating a new scenario named “DrWho”. This was our initial screen:

Then I told Sophie that she has to decide where this game takes place. She said “on Mars”, so we made a subclass of the built-in “World” class, called “Mars”, and hit Compile. Here’s what we saw:


Sophie commented that the world does not look good, because it’s all white, and too small. I told her how to look at the Mars source code, and here is what we saw:


We talked a bit about the idea that the world is a grid of cells (with a bit of scribbling on paper), and that we can specify the number and size of the cells. We ended up changing the parameters that specify the world to:

super(750, 450, 1);

That made the world nice and big, but still white. So next, it was back to the popup menu of class Mars, to choose the Set Image… function.

When you choose this function in Greenfoot, a dialogue pops up showing you a library of prepared images.

Sophie quickly found the category “Backgrounds”, and went through them. She decided on a background image named “space1.png”. After selecting this image and compiling again, this is what our scenario now looked like (the fact that it’s called “Mars” but actually shows space, did not seem to matter at all):


Okay, we were happy with the spacy background, so the real action could begin: Creating the Doctor.

First we googled for an image of the Doctor (there are many!) We chose this one:

Since this is for personal use, with no commercial intention, or even intention of distribution, I decided that this falls under “fair use” clauses, and we copied the image.

Next came a session in Photoshop. Sophie had used Photoshop before (with only a very few edit tools, but at least it wasn’t all new). I enlarged the image a bit and showed her how to use the ‘Polygonal Lasso Tool’ to cut out the background. She was sitting doing this very patiently, with a look of concentration on her face, and got it mostly done. Once or twice I had to help her out when she did something accidentally and didn’t know what she had done. You can really get lost in Photoshop if you don’t know it well, so a simpler image editing program would be good. But she got it done without many problems.

When she was ready, I showed her how to scale the image down, and this is what she ended up with:


Okay, ready to go back to Greenfoot. I told Sophie that she could create the Doctor by creating a subclass of the Actor class, which she then did without problems. Now, in Greenfoot, when you create a class, you can assign it an image. We named the class Doctor, chose our Doctor image, and we’re ready to go. After compiling, we can then immediately create a Doctor object – here is what it now looked like:


Wow! First great success. The Doctor on our spacy background. Sophie was worried that the doctor has no legs, and that it might look funny of he runs around, but we decided to ignore this for now, and maybe come back to it later. We then tried clicking on ‘Act’ and ‘Run’, and Sophie observed that nothing happened.

Time to start writing code!

Now, I decided to give Sophie a fairly simple API to start with. So I had her take a short break, and I quickly wrote a class called “Mover” with the following source code (this is really something you could prepare in advance if you are a better organised person than I am…):

import greenfoot.*;  // (World, Actor, GreenfootImage, and Greenfoot)

/**
 * An actor superclass that provides movement in four directions.
 */
public class Mover extends Actor
{
    private static final int speed = 4;

    public void moveRight()
    {
        setLocation ( getX() + speed, getY() );
    }

    public void moveLeft()
    {
        setLocation ( getX() - speed, getY() );
    }

    public void moveUp()
    {
        setLocation ( getX(), getY() - speed );
    }

    public void moveDown()
    {
        setLocation ( getX(), getY() + speed );
    }
}

The intention, as you can see, is to provide four methods: moveRight, moveLeft, moveUp and moveDown, which provide a little simpler abstraction than the standard Greenfoot API with its built-in setLocation and getX/getY methods. I made Sophie’s Doctor class a subclass of this one, and told her that I had made her Doctor a “Mover”, which means that we could now tell him to move. Ready for Sophie to take over the keyboard again and continue.

Clicking Act or Run still does not do anything, so we open the editor for the Doctor class, and see this method:

    public void act()
    {
        // Add your action code here.
    }

Now, we change this to:

    public void act()
    {
        moveRight();
    }

To do this, I tell Sophie the method name, and also that instructions always have the parentheses and the semicolon at the end. Sophie compiles, creates another Doctor object, hits Run and HURRAY! The doctor moves!

We also try moveLeft instead of moveRight. She quickly gets the idea that we can now make him do things. She then says: “But I only want him to move when I press this key. We need to write something like ‘If the key is pressed: move!'” Wow. I couldn’t have scripted this better. She not only prompts me for the next step, she even almost uses Java terminology!

So next, I told her about the if-statement, and also about Greenfoot’s key checking. We write the following code in the act method:

    public void act()
    {
        if (Greenfoot.isKeyDown("left") )
        {
            moveLeft();
        }
    }

Now, she couldn’t have written this on her own yet, since she doesn’t know what the built-in API methods are, or how to look them up, or what the syntax is. But she quite easily understand the idea and the concept.

The good Doctor, of course, moves only one way now. I just mention that she could make him go the other way with another if-statement. She then actually manages to do this using copy, paste and edit:

    public void act()
    {
        if (Greenfoot.isKeyDown("left") )
        {
            moveLeft();
        }
        if (Greenfoot.isKeyDown("right") )
        {
            moveRight();
        }
    }

That really gets her excited. She also manages to repeat this again for up and down. At this point, she gets her first syntax error (“; expected”). After pointing out the error message to her, she actually manages to fix it. Lucky that we got one of the less cryptic messages to start with! The error messages in Java will surely be one of the great problems we will run into quite quickly.

The next thing we observe is that the Doctor moves backwards when he moves right. I suggest that we make him flip around. Sophie agrees.

So back to Photoshop it is. Flipping the image horizontally to face right is easy, and she saves it as “dr-right.png”. I ask Sophie where in our code we should put the instruction to use the right-facing image, and she works that out correctly. I then tell her what the method name is and talk her through typing the method call and parameter. We get this:

    public void act()
    {
        if (Greenfoot.isKeyDown("left") )
        {
            moveLeft();
        }
        if (Greenfoot.isKeyDown("right") )
        {
            setImage("dr-right.png");
            moveRight();
        }
        if (Greenfoot.isKeyDown("up") )
        {
            moveUp();
        }
        if (Greenfoot.isKeyDown("down") )
        {
            moveDown();
        }
    }

That’s pretty good. But when we try it out, she sees very quickly that the Doctor now turns right, but does not turn back left again. This time, she can actually fix this herself by copying the setImage line, pasting it at the right place, and fixing the image name. I’m happy!

That’s it. We decide to call it a day for today. A live version of what we wrote is on the web here – have a look.

The Greenfoot project we wrote (with full source code) is here. Feel free to take it, and use it for anything you like.

So, in summary: we have managed to get some animated graphics on screen pretty easily. We spent half the time making images, and then some time writing some code. We used a “jump-in-the-deep-end” approach: Most of the code we wrote by me telling Sophie what to write, but she pretty quickly picked up some of the concepts, and she was able to generalise and apply some things she observed.

This is how I plan to continue working with her: from the concrete to the abstract. First, we do things (even if I have to tell her how), and after some time we can hopefully discuss the underlying principles and more formal rules.

But first: let’s try to have some fun and do something!

I hope that I have time to continue this report over the next few weeks or months, when we hopefully make this game do a little more.

Here is the summary for today:

Session #1
Time: approx 80 min
Result (live): DrWho
Source code: DrWho.zip

72 thoughts on “Teaching My Daughter To Code

  1. I would disagree on the Java. Java is far to pedantic a language for that age group: Make sure you have all your semi-colons, have all your brackets in just the right place, make sure to compile before you can do anything with your changes.

    I would love to see something like Greenfoot written in a little more forgiving language, like Python. Even implicit support for Jython would be a happy thing.

  2. Having taught myself to program at 10, I’m looking forward to following this.
    Not only have you got a project that she is interested in doing, it’s also one you get visual feedback of your progress – always a way to keep a mind of any age interested.

  3. This is a good idea. I am also a programer with a daughter of 9 years old. I will follow your dad-daugther programming to be prepare when my daughter will ask for it.

  4. I am sick to death of this stupid OH YOU SHOULDN’T USE THIS LANGUAGE baloney. Especially when fools walk in and say Python. The language that already has kid support much like Greenfoot is Smalltalk on Squeak, so don’t come wandering in here whining they should be using Python. Python has hideous tool support and is essentially java all over again except slower and without static typing.

    He’s using an appropriate tool for the job, so zip it. What is good is concepts he’s trying to teach such as abstraction (what the doctor can do). Stop being such a reddit cliche.

    Good job to the original poster.

  5. I have 2 young daughters and a I am looking forward to the day, soon I hope that I can start working with them on programming. I want them to see and understand my world as well a get a feel for programming while they are young. I hope that such early exposure might help them build skills in reasoning and logic.

    I don’t know about java or python (not touching that argument) however there are other alternatives that seem to be a bit more kid (young kid) friendly for learning the concepts without the hassles of syntax from any language.

    Check out “Scratch” from MIT. http://scratch.mit.edu/
    It was built specifically for helping kids learn programming.

    Here is their blurb:

    Scratch is designed to help young people (ages 8 and up) develop 21st century learning skills. As they create Scratch projects, young people learn important mathematical and computational ideas, while also gaining a deeper understanding of the process of design.

    regardless of how you do it or what you use, good luck bonding with the little ones – maybe they will learn something along the way.

    — Isi

  6. Shut it,

    If somebody suggesting (note it was just a suggestion) gets you that riled up, it makes me really question your objectivity. If something came along that truly was better could you give up being blinded by Java for long enough to consider it?

    Also, I hardly think that speed and static typing are primary factors when selecting a language to teach kids programming. I would argue that a dynamically typed language would be better for teaching kids (Smalltalk, Ruby, Python), languages in which it would be easier to focus on the logic rather than the syntax.

    Good article overall though.

  7. Hi there,

    I applaud your efforts, and hope everything is well with you and your daughter.

    I do want to raise a note of alarm. I recall struggling through Java and C++ syntax as a kids, and though I did get through without too many scars, I remembered much pain upon reading of Natasha Chen’s encounter with programming classes. In this article:

    http://www.trollope.org/scheme.html

    She details how boring classes organized around syntax displaced creative teaching and work. But she then explained how learning Scheme revived the magic for her: that the extremely simple syntax allowed her to focus on the ideas directly, learning, all the way.

    I love Scheme, and it would be a great choice. Squeak, too would be terrific – it seems to have been developed with kid’s exploration in mind: (see for example, http://www.squeakland.org/kids/kidsmain.html). Even Java might not be so bad.

    But I would take caution. Making GUI apps in Java wasn’t very fun. I recall my frustration with Swing and exception hierarchies and paths and packages and altogether it’s just not an experience I would revisit. Maybe it’s better to learn something designed to be easy. Something, designed to grow with you.

  8. I can see this in 20 years later, all the fat ruby kids making fun of the C kids and calling them garbage collectors and memory leaks whilst the haskell guys quietly study in the corner.

  9. Shut it, You have observed correctly. Both Python and Java are Turing-complete. Congratulations.

    Michael, this sounds really cool. I’m going to check Greenfoot out. 🙂

  10. Did all of you suggestion alternates read the article? The author is involved in the Greenfoot project and has taught it to 15 year olds. He is specifically looking to see how it works with his daughter.

    So stop throwing in your alternates.

  11. I agree with shut it, to a certain extent: Python is indeed pedantic. Main reason I went with Ruby instead of Python for day-to-day stuff was that I could go with an oo language that WASN’T quite as pedantic.

    However, I could see how Python would make a great teaching language. I mean, after all, when you’re doing simple things, it’s simple to work with, and it teaches you to think in terms of code blocks, proper indentation, etc. without being TOO annoying about it.

  12. Lovely post! When I was your daughter’s age, my dad gave me his old ZX Spectrum and several books about programming for children. It introduced all the basic programming concepts with big colourful characters who needed help with their math, make grocery lists and in the end play simple games like Hangman. Nothing fancy, it was all in Basic, but I loved it.
    Those experiences helped me understand computers and develop an abstract way of thinking that I’ve enjoyed in the rest of my life. You can’t start too early 😉 Good luck on finishing the game with your daughter!

  13. When I was younger, I always wanted to do things with the computer, but never enough to trudge through classes, syntax, libraries, etc. I finally took some C classes in college and taught myself Python, and I just think it’s great that Sophie has you there to help break the project into manageable chunks.

    Without the benefit of a parent who’s not only a skilled programmer but who has experience teaching kids to program, I’d think Java would be a very frustrating language to start with. Even now, when I get an idea for some program I’d like to have, the thought of writing it in C makes me recoil in memory of segfaults and worse. I love working with Python because I write a dozen lines and it already does something interesting. It sounds like your little module-writing and library-searching help is really giving your daughter that sort of pleasant experience, and it’s probably even a benefit that she’s getting familiar with the brackets and semicolons without having to master them yet.

  14. My six year old can use scratch. Not well, obviously, but she had a sprite being pushed around the screen using keys the other day. I just installed it, gave her the “get going” book and left her to it.

    Scratch is awesome.

    From a purely pedagogical standpoint I also think it’s interesting to ask how much longer static languages are going to be around.

  15. Thank you all for all your comments.

    I’d just like to briefly reply to some questions and suggestions.

    Yes, I do know Scratch and Alice and Squeak and Logo (and other systems of that kind, such as Geroo, Karel the Robot, the MBCS and GridWorld, etc.)

    I agree that Scratch and Alice are great systems for kids – no doubt at all. The reason I am using Greenfoot is personal: I know the system very well (I am deeply involved in its development), I have used it for teaching before, and I think this expertise has value in making the process easier, and I want to make use of it.

    (Squeak is another matter. Has anyone making these comments actually used it for teaching? I have seen Alan Kay do his demo several times, and it’s one of the best demos I’ve ever seen. Really impressive. But at the same time I always get the feeling that nobody but Alan Kay could do it. Squeak is amazing, but not really easy to use for beginners. I couldn’t see myself do it.)

    Usually, Greenfoot has a slightly different target group than Alice and Scratch. The target group for those systems is a little younger. Greenfoot aims mostly at secondary schools (as I said, we mostly work with 15-year-olds, or thereabouts).

    As a solo activity, Greenfoot would not be the primary choice for Sophie’s age group. Nonetheless, my judgement is that as a one-on-one guided activity it can work. We will see.

    Alice and Scratch certainly are wonderful for kids. Greenfoot is a little more demanding, but offers advantages in the other direction: you can do a lot more with it. You don’t run into the same boundaries as you eventually do with the drag-an-drop language systems.

    And regarding Java: Yes, the syntax is strict, and is a hurdle initially. But for how long? How long does it take a 10-year-old to get used to it? I guess the answer is that none of us really knows. We will see.

    Regarding the comment that Java is too boring, Swing too complex, etc: If you look at Greenfoot, you will have noticed that this is not you standard Java IDE. Yes, the language is standard Java, but you get going with graphics immediately and easily. We had moving graphics on the screen after a good half hour. And that was only because we made the images ourselves – using an icon from the library, it would have been five minutes.

    And I don’t think that Java with Greenfoot equates easily to an experience of learning C++ some years ago.

    As I said: we will see. Thanks for your interest, and I’ll try to keep you posted.

    Michael

  16. Good article and glad you posted your experience. I do feel compelled here to give another plug for scratch because I did exactly what you are doing with my kids but used scratch. In fact, the scratch code to build the simple moving animation you did is considerably easier while getting across the same teaching points. Thus, for green foot I would highly recommend you reuse some of the concepts in scratch.
    The only downside of scratch is that when I was creating an asteroids game to show the kids something non-trivial – the lack of arrays really hurt.
    Lastly, as someone who has a high-school freshmen taking a C++ course in school, let me assure you that Java is a better approach. There are too many complexities and gotcha’s in C++ that I either have to gloss over with my son or explain in a “short-cut” manner.
    Best wishes,

    – Mike

  17. > quickly wrote a class called “Mover”

    Maybe a little too quickly, the Javadoc comment has a mistake in it… 🙂

    (“superclass”)

  18. Well, I’ve written games in C++, Java, J2EE, Flash, etc, but the easiest has got to be XNA. C# is so easy to get used to and why not write something that can be deployed to your 360 while you’re at it?

    Take a peek at it here: http://creators.xna.com/

    There are plenty of tutorials there and on the web, too.

  19. My compliments to your daughter for her obvious intelligence and curiosity, and to you for being willing to take a risk and teach her all this. Something like teaching a child to write programs can seem like a mammoth undertaking, but it seems like you’ve provided a great start with, as some others have mentioned, great (and instant!) visual feedback, which is fantastic for younger minds.

    I think it’s especially advantageous for your daughter that she has a parent, somebody who knows her very well, who is willing to teach her. It means her teacher knows a bit more about her learning style than most, which can only help. Of course there are disadvantages, but I can’t think of any at the moment :o)

    Congratulations once again to both of you.

  20. Mik, are you letting your daughter read this page? I think it is vitally important that she learn as quickly as possible that programming is not about having fun, spending time with her father, and actually creating something that works, but rather about griping about language choice, tool impracticality, and the idiosyncracies of management.

    The sooner she learns this the happier she’ll be, if by “happier” you understand me to mean “jaded and bitterly disillusioned, like everyone else in this thread”. This is why learning programming really should wait until you are 14 or 15, when you’ve pretty much figured out that life, and everything in it, is crap.

    You’ve got a 10yo who is interested in making something work so much that she’s willing to play with and learn the system–ANY system–to make it happen?

    WIN.

    Anybody who does not understand this is missing the point.

  21. I now have this blog bookmarked. Please keep us updated. Before this post, I hadn’t heard of Greenfoot, and I think it’s wonderful that you’re taking the time to share the teaching process with the rest of us. Your daughter is very lucky to have a parent like you.

    Good luck to you both.

  22. It sounds like Mike is a great teacher. He is letting her type and explain things that can be explained at this level. The idea is to get something out there. Teach a little then let her add on it, like showing her how to move up then let her figure out how to move right.

    All of this talk about what language is really mute. He is using Greenfoot because that is what he is comfortable with. Obviously she is not going to be a programmer tomorrow. But with the lessons learned she may find enough interest to learn how to learn. Once the exposure takes, I am sure she will explore all of the other languages all of you have mentioned.

    I really like the comment David made…pretty cynical, but most of you bring it out.

    I think this is a great project, and as mentioned, I think the block approach and letting her lead the concept is great. Good Luck Mike and Sophie!

  23. Man, sounds pretty sweet. I started out programming around that age, messing around on a TI-83+, and the way you’re teaching her reminds me a little of how I learned. Just sort of jumping in and figuring things out as they go. At least for me, it worked pretty well, by my last year of Junior High I had programmed a working (if slow) version of Tetris. Never looked back, currently learning how to program games in college. Best of luck in your endeavors ^_^

  24. Nice. At that age, they can learn anything as long as you give them access tot the information they need.
    I remember that I was hacking in 8-bit assembly at age 11. So when I read one of the previous posters stating that Java might be too pedantic for kids, I can’t help but laugh. They’ll understand sooner than you’d expect.

  25. Michael,

    You’re daughter appears to have handed you a case study on a plate! This will make for interesting reading as it goes along.

    Hope it keeps its momentum, and most importantly, you two enjoy doing this!

    Steve

  26. Pingback: » Daily Bits - January 22, 2008 Alvin Ashcraft’s Daily Geek Bits: Daily links plus random ramblings about development, gadgets and raising rugrats.

  27. Java sucks. If someone just wants to learn how to code, use VisualBasic. Simple syntax, good practice. From there, move to C#. Case sensitivity and unsafe operations allow for some easier understanding and more powerful projects. If you’re really hardcore (or masochistic), move from there to unmanaged C++. Almost the ultimate in power, but rather complicated. Java is not on that list at all. Java has two uses: browser apps, and cross-platform compatability. But that’s what C is for. So it has one purpose. Java is an over-simplified C++ without the .NET framework support. That makes it nearly worthless in my book.

  28. Pingback: Your First Programming Language Needs A REPL | Programmer’s Paradox

  29. dude, RUBY (Duhh!!) there can’t be any easier syntax to start with than ruby, and there’s even hackity-hack (ruby training program for 8th graders). I realize 8th graders are 14 usually, but I really do think the combination of language/learning tool in this case is by and large the most effective. You could mention to her that if she still knows ruby really well when she’s 18, she’ll start out in the field at like $70,000 annually.

  30. Pingback: Michael’s Random Thoughts » Teaching My Daughter To Code, Part II: Invasion of the Daleks

  31. please take your daughter seriously and don’t condescend to her! when i was twelve and female in 1987 i wanted to write a word-processing program (“somewhere that you can just type”, i thought). unfortunately, i was the most tech-savvy person in my family at the time, so bill gates beat me to it.

  32. I think Scratch is a lot easier for kids to pick up. My 7 year old started making things and figuring out procedural thinking right away.

    Hackity Hack looks interesting, but I haven’t tried it yet!

  33. As a 14 year old Python programmer, I find this very interesting. I started learning Python a few months ago, and now I make full apps with GUI’s, and I am just beginning 2d game programming.

    I will be sure to keep up with your project, your daughter is very lucky; I sure would have wished I had learned Java at a young age!

  34. Way to go, Mike. It happens that this afternoon I’m giving a talk to high school teachers about using game programming to stimulate interest in Math and science.

    (I’ve written two books on game programming, so people mistakenly believe I know something about it.)

    I love what you’re doing, and it parallels my attempts. I’ll definitely look into GoodFoot. I’ve taught kids with Squeak (agree – it’s cool, but Smalltalk is just too complicated) Scratch (love it) Alice (OOP stuff is too much for younger kids – they do animation but rarely get to real interactivity) and Python.

    Python / Pygame is still to complex to use with kids, but I’ve written my own library on top of pygame (gameEngine – simpler than livewires) I’ve had some success teaching with this library. With younger kids, I just give them the library and teach them how to use it. The older kids learn how to build and modify the library.

    I also teach CS1 (using Java) for a major university. I don’t need to tell you how silly these language arguments are. (The language I know ROXXORS – others don’t)

    If Sophie is interested in discovering how to manipulate code, you’ve won.

    First, she’ll make him move independently, but then she’ll want to make him bounce off the walls. She’ll ask you about how that works, and you can explain the relationship between position (x,y) motion (dx, dy) and acceleration (ddx, ddy) You don’t have to tell her that these are ideas that most calculus and physics students struggle with truly understanding.

    Next she’s going to ask you about frame rates, and how 30 fps is close enough to continuous motion. You can explain Nyquist’s law and the fundamental theorem of calculus, or you can let her discover these things with your guidance.

    Next she’ll observe that the good doctor travels faster on diagonals than he does along the X and Y axis (because no doubt she’ll make him go diagonal by setting both DX and DY to 1. A little bit of Pythagoras will help her see how to get a diagonal speed equal to the horizontal and vertical speed.

    After that, she’ll ask how to make him move in any direction at any speed. If you can stand it, you’ll try to make her figure it out on her own. She will fail, but then she’ll ask for help. Then you can show her vector projection (DX = r*cos(theta), DY = r*sin(theta)) and why these two formulas are the game programmer’s best friend.

    In short, by playing, discovery, and the guidance of a skilled mentor, she might actually learn something.

    I’m inspired. I can’t wait to see more. (And Sophie might want to meet my Elizabeth some time. She’s 11, and doing some of the same stuff.)

  35. I’ve found UCB Logo to be a fantastic language for teaching children how to program (mine are 9 and 12). The free online text books from Brian Harvey are excellent. Don’t just think “turtle graphics”. Think the power of Lisp with a friendlier syntax. I personally think children can pick up imperative languages quite easily, so I’m glad to expose them to a functional approach to broaden their horizons.

    http://lojic.com/blog/2008/01/05/learning-logo-part-one/

  36. Michael: I too have an inquisitive child (my son is 8) who is unsatisfied with playing games and wants to make his own. We started would with GameMaker when he was 6 and made a couple playable action games…but it’s so much like VB script I was hesitant to encourage him to learn it well! Then we found Squeak…yeah, you’re right about the complexity for a young child — I couldn’t leave him alone with it. Next, Alice. That is very promising, but a little restrictive for what he wants. I will be following this blog, too, with great interest.

    Thanks!

  37. Hi Mik,

    Well, you caught me. I haven’t used Squeak for teaching, unless you count myself. But I can imagine a younger me learning and enjoying it. The idea that it’s built in itself is deeply satisfying, and would have been to me while I was a kid.

    I haven’t looked *too* deeply at Greenfoot but getting moving images that quickly sounds impressive. I may end up letting my brothers know about it, though, truth be told, they seem to be more interested in scripting and modding existing games.

  38. Pingback: Michael’s Random Thoughts » Teaching My Daughter To Code, Part III: Prepare The TARDIS!

  39. I learned to program by teaching myself Apple Basic on my parent’s Apple IIe but that’s not what I would suggest for kids these days…

    Instead, the best programming learning experience I witnessed was in a text-based virtual world in my first year of University. The course was on ethics in engineering and the MOO (MUD, Object Oriented… MUD stands for Multi User Dimension) was simply a tool to allow anonymity so we could study its effects but the MOO was programmable and interactive. The whole year spent a great deal of their time chatting with other students through the MOO and writing programs that were not part of their course work to show off to their friends.

    I also remember that seeing your creation actually being used by other students was an incredibly proud moment. I had written many programs by the time I reached University but I had never had one actually get used by anyone else before. That spurred me on more than anything had done before.

    Setting up your own MOO is quite easy but, again, not what I would suggest. I think that making simple and easy networking part of the Greenfoot API would be the catalyst that gets your daughter and your friend’s daughter working on the same game. They both have a copy of the source code and they email each other their changes. Once they have compiled, they can connect and play against or with each other in the game that they wrote themselves. Before you know it, they will be conscripting their friends from school to join and you’ll have a MMORPG running out of your house.

    Oh, and as a final note, I’d like to chime in with the you’re-an-example-of-a-good-dad sentiment. Paying attention to what your daughter wants and finding a way to have her attain it herself is the very paragon of good Dadding in my books. Well done.

  40. Pingback: Michael’s Random Thoughts » Teaching My Daughter To Code, Part IV: Return of the Daleks

  41. Hi Michael,

    it’s really cool to see what kids can do today and that they are taught OOP from scratch.

    I’m from Germany and taught myself Basic on my first XT with a monochrome screen in 1992 when I was 12. Hardly understanding a little bit English and writing programms in an abstract language can be very challenging. 🙂

    Never wanted to be anything else than a a programmer since I was 14.

    Happy Coding!

  42. Michael,

    I was able to teach my son some programming lessons at 9 years old using KPL (Kids Programming Language). Granted it was only geometric shapes,moving sprites around the screen and changing colors, but he caught on with procedural languages quickly. OOP is taking longer. He’s 11 now and getting into Algebra. Hopefully, he’ll catch on soon.

  43. My first experience with programming was CBM BASIC V2 on the C64, but I quickly exhausted that and went onto 6510 assembler, which is where I really learned to program. Mind, I was 17 at the time (there was no such thing as a home computer when I was 9!).

    All computer languages have idiosyncrasies and if you’re going to teach a child to code, no language is really better than any other. BASIC is easy to learn, but it teaches bad programming habits, like “spaghetti code”. C and Java can be cryptic and very syntax oriented. But C and its derivatives (C++, Java, PERL, Javascript etc) are probably a good place to start because most 3GLs use the conventions of C.

    The important thing here is that the child should grasp the fundamentals of programming while developing the game: variables, functions, flow control and looping, and structure. Greenfoot looks good on this point by graphically illustrating structure and containment; a picture paints a thousand words especially to a child.

    I’ve bookmarked this page and will follow your progress with interest. I’d like to see how quickly Sophie learns these concepts and how quickly she climbs the learning curve.

  44. I absolutely LOVE Doctor Who, and I’d like to learn this as well. For AP Computer Science this year, my class used “Gridworld” which seems to be very similar to Greenfoot. I wish my dad had taught me at 10, because I only just got into Java about 2 years ago. I may try to replicate this when I get some time this summer.

  45. Dr. Who + programming + parenting! What could be better?
    I think this is really neat. I starting skipping the comments when it turned to the language wars, so I apologize if someone said this.
    I like the idea of teaching my children to program because it wraps up two essential things: creativity and problem solving.
    I remember Kent Beck talking about teaching his daughter to program in his TDD book.
    (Here’s my daughter on development tools: http://www.youtube.com/watch?v=7kMV7dPDgC4)

  46. My kids use Scratch mainly because of the excellent visual approach to constructs like loops and branches means that they just get it. We also use BlueJ in the office to teach science graduates ‘day 1’ programming before throwing them in the deep end.

    I see greenfoot as being the modern equivalent of BBC basic, but I don’t agree that is offers design insight. System and software design is a different skill, one more suited to bamzooki.

    I think what I am trying to say is that this is already a well explored space.

  47. Pingback: How To Teach Programming To Kids | Chris Pirillo

  48. @Comment #2:

    Ha. I don’t think so. I’m only 13 years old and I can program in Java, C, HTML, PHP, batch (yea I know), umm… assembly, a little bit of C++, VB (again, yea I know), python, and Linux/Unix Bash (SH).

    Yes. I said I am only THIRTEEN years old.

  49. I’ve been teaching elementary aged kids (6 – 11) Python programming and it’s going pretty well. Learned a few things from your blog as well, thanks!

  50. Pingback: How a $25 USB-stick-sized computer could improve Programming Education. | HickA.US

  51. Pingback: Five easy steps to get you coding | memeburn

  52. I really don’t have idea how to make programming and search for such kinds of article.I think it will help newer and inspire more to try…

  53. Pingback: Mengajari Anak Bagaimana Menulis Program Komputer | Ilmu komputer Untuk Anak Indonesia

  54. Pingback: Teaching My Daughter To Code, Part II: Invasion of the Daleks | Programming Education Blog

  55. Pingback: Teaching My Daughter To Code, Part III: Prepare The TARDIS! | Programming Education Blog

  56. Pingback: Teaching My Daughter To Code, Part IV: Return of the Daleks | Programming Education Blog

Leave a Reply

Your email address will not be published. Required fields are marked *