Hacker News new | comments | show | ask | jobs | submit login
My 7-Year Old Daughter’s First Programming Experience (dancali.io)
80 points by idancali on Apr 6, 2014 | hide | past | web | favorite | 61 comments

How young can a child learn to program?

While I'm not ready to indoctrinate my four-year-old into the monkhood of true geekery while he's getting in his prime running around time, I was curious to see how logically he could think. My layman's knowledge was that children began properly interpreting and creating rules around the age of six, while four was still wild imagination territory.

For my experiment, I created an extremely minimal programming game, like a very stripped-down version of RoboRally: https://dl.dropboxusercontent.com/u/5458223/robot_factory.jp...

The image depicted is doctored. We had already completed four playthroughs the night before with a similar setup, however. He was able to figure out how to program the robot to collect all of its pieces (three Duplo blocks comprised the robot; successful completion of the robot wins the game). I demonstrated the rules once, and then let him try to play by himself with minimal guidance. One interesting strategy he discovered was placing the "instructions" (the cards with arrows) on the game board in order to create a path. https://dl.dropboxusercontent.com/u/5458223/robot_factory_re...

A few weeks later, we played it again, and I taught him how to make new "instruction cards". We're not yet at the place where we've done anything with variables and abstraction. Apparently he liked the game well enough, because he independently recreated it at school:

A child using language functionally to get what he or she wants is essentially a form of programming. Example:

    1. result = ask_parent_or_candy(mom, nicely)
    2. if result != candy:
    3.     ask_parent_for_candy(dad, nicely)
I studied analytic and philosophy of language, and i feel that many people in CS don't see the forest through the trees when it comes to programming as such. While some code (e.g. C) handles much more technical aspects of what is actually happening, scripting languages are much better suited to the human mind, and i think creating a natural language language (<-- that seems a bit redundant) is an achievable goal.

If i had a child, i would start her out on python, because python is essentially in english, and english is the only code i'd prefer to write, given the choice if there were a formalized english scripting language.

Even in python there is a bit of jargon that i think is an unfortunate holdover. Int vs float may be necessary, but "string" is a poor term for what is essentially text. I'm not saying we should change anything, because coding is becoming more like natural language organically, but again, if i were to teach my child coding (and i don't want to step on any cuteness of this story), i think a child would understand python better than anything with brackets and semicolons.

Full disclosure: i genuinely like python better than most languages.

You're mistaken I think. Computers essentially process numbers, and even though they are okay for building abstractions, they invariably end up leaking. The complexity in programming is not in the language used to describe it, it's in the details of actually making it work. Syntax is generally irrelevant and only exists to make things easier to read. Also jargon like "String" is actually a holdover from formal logic (so analytic philosophy!).

Also, "There will always be things we wish to say in our programs that in all known languages can only be said poorly. " -- Alan Perlis

I completely agree with the fact that syntax is irrelevant. What's really key in coding is getting the core concepts down, like variables, control flow, methods, classes, etc. To me, if a kid can understand what a variable is and what a value is, that's awesome, I don't care what language it is. Once they pick up the fundamentals they can go and teach themselves whatever language they want.

Fair point on "string," though i never really encountered it, i opened up an old goldfarb book, and it's not in the index, but it looks like it is used in my old enderton "mathematical introduction to logic," so, again, fair point. I think "statement" would be a better term, maybe.

enderton page 107, 289, etc: http://books.google.com/books?id=dVncCl_EtUkC&printsec=front...

yeah I wondered about string myself, I don't see how a child could get "strings". I think they would get "letters" or "words" or even "text". That's why I just didn't get into strings, I just let them type stuff and see the result of what they were typing in the simulator which was thrilling. And when it came to teaching variables I went with int's. Even that was a long shot. I just went with "it's just a number" and I think that should be sufficient for lesson #1 :)

I actually thought about what I should start with if I were to teach coding and you're right I would probably start with something that's interpreted first of all. I was thinking Ruby , perhaps Python, you're right.

But the crazy thing is that I didn't plan the whole thing. It was more of a "lets build an app together" type of thing. My kids and I have been talking for a while about building an iPhone game together so that's where the whole iOS thing came from.

But you raised a good point. If you had a choice, what would be the best language to start off kids with? And maybe you're right, maybe there should be a new language built just for this purpose.

Maybe a bunch of us coding dads can create an open-source mini-lang of some sort with the sole purpose of teaching kids to code.

I feel the language is not as important as the standard library. It should be easy to make interesting things happen. This is where classic BASIC implementations were great. You could just say 'LINE 1,1,50,50' and there was a line.

How many lines of code would it take to draw a line and circle in objective C? How many of those lines would be indecipherable boilerplate?

I'd love to see Logo have a bit of a revival. It's great in that kids can start making pictures immediately, and learn more sophisticated syntax as they need it. The only thing that would make it more appealing to children would be a physical turtle. Maybe a pen plotter would be a reasonable substitute.

I also like that it can be completely open-ended what kids do, like crayons and paper instead of the awful stuff they have to do in computer labs at school. (play stupid games that drill the facts you'll need on the standardized test; win virtual money you can spend on accessories for your avatar; vomit) See Seymour Papert for similar rants.

All that to say, a slight modernization of UCBLogo would be a fantastic project.

I figured you didn't start out with the intention, but yes, i agree that building a simple language for kids would be a very good idea. Perhaps you wouldn't even need words at all. The entire point of generative grammar, if i'm not mistaken, is that logic is pre-programmed into the brain.

You know a long time ago I used to "code" in this language called LabView and it was all graphical. It was designed for electrical engineers. I remember working with electrical engineers that had no idea about coding and they would be able to build complex systems in LabView. You would drag and drop a box and attach it to another box with a connector and that would be a loop, etc. Really awesome. Maybe something visual like that, with colors, animations etc would work for kids.

This reminds of the examples used in The Poignant Guide

   1. front_door.open
   2. front_door.is_open?
   3. front_door.paint(3, :red)

When they're old enough to play music. ;-)

I'm no psychologist, just a parent of two curious kids. I think a lot of things come together at around the age when kids are reading, and beginning to write.

Another question I'd think about is: When is a child too old? Those years around 6 to 12 (give or take) are a beautiful time because kids are curious and active, but they haven't yet fully internalized all of gender roles and rules about who can be interested in what. Also, they are still at least a few years away from that terrible age when things like GPA and job skills matter, so they are free to explore interesting subjects for fun and not according to any particular set of rules.

It's interesting actually, not that you mention it, this week my daughter read her first 20 page kids book. In English, as her second language. Her first language is Romanian and we speak Romanian at home. I do believe this is a beautiful age for kids to see what their brains can do. There's so much potential at this age, and if their curiosity is fostered they end up doing amazing things and starting off with the right foot in life.

With web programming, a lot of the initial hassle and set up is gone, and visual learning/iteration by hitting refresh is very easy. So I would say, almost as young as they can play around with a web browser, and type on a computer. You can immediately start seeing results by typing in the Chrome inspector console. I think even a 4-year-old would be able to understand an if/else, but I'm not behavioral psychologist.

yeah that's a good point; I really wonder about conditional statements though, I think control flow should be straight forward, but I would think you might need to start off with variables and primitives at least.. what do you think?

Agreed - you can't really do much without variables/primitives first. Which are might be conceptually harder to grasp

I started using DOS to run games at around 4, when my dad bought a PC, and taught myself batch programming and QBASIC when I was 6, so I think the ages you mentioned are probably correct.

(For many months, I had no idea there is such a thing as "else", so I used to end the body of "if" statements with a "goto" to jump over the next few statements to emulate the effect of an else clause.)

haha that's awesome, I had no idea about a lot of stuff when learning but that's the amazing thing, you don't need to know everything to get started and start building things, and that's what scares people off, they think they have to get a math or comp sci degree to code something basic

that's great man! I'll try that with my 3 and 5-year old boys to see if they pick it up. I was thinking about the whole "how young can a child learn to code" thing too and I think it's obviously a matter of the environment they're used to. If they create a lot, arts/etc, play with Legos for example at a young age, that sort of stuff, they might be inclined to pick up more abstract things at a younger age. My daughter likes doing a lot of math stuff for fun and she has a tendency towards numbers and abstract thinking so she picked it up naturally. We'll see how the boys do in a couple of years :)

Your game is reminiscent of http://www.robotturtles.com/

I don't have kids, but even if I had this entry would still be totally worthless for me. It's touching and nice, but can anyone learn anything from it? I don't really think that there are any useful tips on teaching 7 year old anything, I would even say that it's quite opposite, how could anyone post code like this in such context: @property (nonatomic) IBOutlet UILabel* label; ?

Even if a child does not fully understand everything, the child DOES understand that when they type an instruction, the computer will execute it! This is exciting, akin to finally getting that the squiggles on paper are words and letters, even if you don't know them and can't quite read them yet. The next step is to build up concepts, like executing steps in a loop, or storing information and getting it later, or starting and stopping. This is all worthwhile, even if you can't quite see it from where you are standing.

right on!

I hear you, but if you check the timeline of the lesson, I didn't teach her every step of the code, that would be too much info off the bat. I wrote a bit of boilerplate code and her lesson - as I mentioned in the post - was just those 3 lines where we talked about variables mostly.

I agree, kids are pretty good at isolating something they understand from the rest and just stay focus at what makes sense. If there's a piece of code that makes sense and they wrapped their heads around it doesn't matter if the rest is gibberish.

I think that's a really good point and it's key in adult learning as well. So many times we go through tons of boring theory first until we're drained of our mental energy and by the time we get to the fun part we couldn't care less. I love courses where you do stuff right away and they tell you, "don't worry about this other stuff for now, we'll get to that soon"

Have you considered that XCode and Objective C may not be the right tools for the job?

on second thought I think you're right. I think it wasn't so much about the tools as much as it was about the concepts behind what coding is, what a variable is etc.

Something like Scheme would be appropriate.

Scheme with graphics (i.e. a LOGO module) sounds very good. Kids are much more impressed by getting pictures to appear than seeing a number output.

This has been a super fun thing in our house: http://scratch.mit.edu/ It's also something a 7 year old can use on his or her own to learn concepts and make fun stuff.

For Android devices, there's also MIT App Inventor, which is a very scratch-like environment for writing mobile apps, available here:


In addition to basic I/O and animations, it's able to deal with a lot of the device capabilities, including SMS, GPS, dealing with the camera, and so forth.

Unfortunately, I don't know of any similar environment for programming iThings --- Apple fairly famously rejected a Scratch port from the app store in 2010:


although a "Scratch player" for Android is in alpha, and apparently, people are also working on pure HTML versions.

There is an app called Hopscotch for the iPad which is of similar structure to scratch. I can't recommend scratch highly enough, the kids at my local coderdojo really do some great stuff with it.

http://learn.code.org uses the same [Blockly?] interface, just tried the first few stages with my 4 year old this last week. Only problem was his general literacy; but he sat on my lap and did the thinking for the problems and I read out the text. Have used Scratch (and light-bot and various turtles) before too with an older child.

learn.code.org has quite a few interesting facets, including using Angry Birds and Plants vs. Zombies artwork; they also integrate light-bot as one of the avenues for learning.

There's also Blockly [0], which you can use to build similar software.

[0]: https://code.google.com/p/blockly/

awesome thanks for the tip, I'm gonna check it out

I'll second this. Install Scratch, then stand back and let the child lead.

Wow that's great. Thanks for the tip. I'm going to check it out.

This is brilliant and amazing to read.

What comes to mind is, we need a list of analogies in the most simplest form so that we can explain fundamentals like variables to kids. Hell, anyone who doesn't know how to code really!

75. HN reads and smiles

I think you nailed it my friend. That's exactly what was going through my mind as I saw myself trying to teach her what a variable is. My boys were playing with Legos and I was drinking coffee so I'm like alright, let's try that. We went through other analogies that I didn't blog about but one of them was how the whole IDE window (XCode) is like a table that you draw on and how a program is like a drawing you make in art class. So the purpose of coding is to use an IDE to create programs just like in art class you draw on a table and create art work. Also, just like you need pencils, colors, etc, in coding you need variables, methods, etc.

Kids get stuff like this really fast.

I'd be interested to see some more examples you come up with if you continue to teach your kids.

I'm re-learning basic trig right now for drawing OpenGL stuff, and I was trying to think what I could have told younger-me on why I should be paying attention in high school for this topic.

When I was in high school, it would have made me more attentive if people said, "Hey, this stuff that finds circle arcs and radius, you can use this in real life if you decide to get into gaming, graphics, .. (and other cool topics that would excite me)."

Yeah it'd be interesting for me too to explore this further. Stay in touch via my twitter @idancali and I'll post stuff as soon as I get a chance. Until then, check out this post I wrote recently: http://dancali.io/blog/you-too-can-become-a-computer-program...

It's about how I decided to pursue coding as a career when I was in high-school.

I think the main thing is to tell younger kids that coding is an art just like drawing and that there is no right or wrong way of doing stuff. They should not be afraid to break things and experiment and they should absolutely have fun building things, seeing things come to life. That's what got me into coding in the first place and I think that's what makes a world of difference. The rest, the variables and things like that are secondary.

I think it's great that the author found something that worked for him and his daughter, but this particular example seens a little complex. The first code I ever wrote was something like


20 GOTO 10

That's 3 or 4 steps. No IDE, no GUI, no variables. A program I could re-create completely on my own the next day.

Hey I hear you. When I started coding I was 9 and I did something like that in BASIC. It was awesome. I was actually considering what to start out with and I just went for iOS off the bat to see what happens. I also think kids these days pick up stuff way faster than 20-30 years ago. It's insane how fast they pick up things like touch interfaces, smartphones, tablets, etc for example.

Same here. I have a one year old now, and was just thinking how sad it is that there isn't an equivalent of a C-64 any more. Turn it on, bam, a BASIC REPL in less than a second. Give the kid the language manual (all of 10-20 pages) and off they go.

Today, there is all this cruft they have to be shown (Cmd-R, XCode, etc.). If they screw up they can't just reboot.

There are benefits of course. Knocking out the power cord doesn't destroy the work in progress. There are non-volatile media. Screens have colors :-)

I wrote a post some time back on teaching my kids to code, thought I'd include it here in case anyone found it useful.


Every now and then I do "math" with my son (5 years now).

I just use a terminal and "bc". He loves to type in numbers and + or * and see the result. And for + we "guess" ahead of time what the result will be.

What amazed me early on: bc has variables. I explained it to him and somehow he immediately got it. You say A is 5 and B is 1 then A + B is 6.

His attention span is usually around 5 minutes, but each time it's fun.

Good stuff and congrats. I'm always amazed to see young kids get into coding and math. I think that's awesome.

I was so pleasantly surprised when she got the whole variables thing. I think drawing analogies to real life stuff is a sure way to get kids engaged, especially if the props you use are toys. About the attention span - yeah I noticed my 5 (almost) year old wanted to try when he saw his sister having fun, but then he got bored after a couple of minutes.

My 6 year old and I often boot up the old 8-bit machine that I have reserved in a corner of my lab just for this purpose. I have to say - there is no better way to teach a 6-year old to code than to fire up a BASIC-running 8-bit machine from the 80's and let 'em at it. Something so satisfying about hearing him read out his code .. "10 ... do this .. 20 .. do that .." ;)

That's one of doing it...the other would be something like this [1]. Not ashamed to say I had to beat the whole thing the first time I saw it because it was so brilliant. And I normally hate pointless puzzle games.


More apps should have a video showing you the gist of what's going on like they do.

that's look really really interesting! I was actually thinking of looking into tablet apps that teach kids stuff like that in a fun way. Thanks for the link, I'll check it out

The author correctly says 'pieces of lego' into the cup - but previously says 'playing with their legos'. I'm sure they wouldn't say 'the children were looking at the sheeps', and then later on say 'the children counted the sheep'.

For whatever reason, this irks me when reading as a grammar error. It's like a klaxxon sounding in the middle of the sentence.

I know what you're saying, and the funny thing is that when I wrote that, I actually paused and thought about the proper way of referring to LEGO. So if you google "playing with legos" there's a ton of articles that use that expression, such as this one on HuffPost for example: http://www.huffingtonpost.com/2014/01/28/google-legos_n_4681...

So kids 'playing with their legos' is valid given the fact that LEGO has become a household name and LEGO can refer to the brand, the game itself, while Legos, or legos can refer to the LEGO blocks themselves. It's sort of like using Google as a verb (http://en.wikipedia.org/wiki/Google_(verb))

Thanks for reading btw

PS. English is my third language so a grammatical error here and there wouldn't be that bad anyways :)

'Legos' is a very North American term so you may have just picked up an (incorrect) slang.

This was an interesting discussion if you're genuinely interested: http://english.stackexchange.com/questions/10839/legos-not-l...

Most North Americans will have been brought up with the incorrect usage, and will defend it strenuously, but they are wrong. The correct plural is Lego, or, if you want to get specific (as you did in the article), lego pieces or lego bricks. The company spent many years trying to teach correct usage but gave up in the end. But correct is still correct, and if english isn't your first language, there is still time!

Even in the verb usage 'kids playing with their lego' - you don't pluralize the term.

That was totally awesome + cute. I have 5-month old girl and can't wait to teach her to program! :)

Awesome, let me know how that works out :)

I like the focus on variables and values - very cool! congrats!

thanks dude, I do believe that's the first fundamental concept that makes most sense in a 101 course/lesson. If you get that, you can move on, if you don't, then you have no ground to stand on

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact