HACKER Q&A
📣 indepnd

How do you teach 9-year old to code?


Yesterday my son (will be 9-year old in a couple of months) asked if I can teach him to code. Although I am a software engineer, I never thought about that.

My question is: If I do, what language should I teach my son at first? Currently I'm mostly familiar with Rust, and a little Python. I used to write C for 10 years and Java for 3 years. I also use Objective-C. I think, as common sense, I should use the language I am mostly familiar with (Rust), but I doubt that's a good idea for 9-year old.


  👤 gregjor Accepted Answer ✓
Reframe your approach: How do you encourage your son to learn programming and stay curious and motivated? You can't teach anyone unless they have the motivation and interest to learn. Kids have lots of natural curiosity so you need to take advantage of that. You need to keep the interest going with challenges and successes.

Do the simplest possible thing to get your son interested in anything remotely like programming. The other comments have some good suggestions. With some success at simple things like animated robots and Minecraft and Mindstorms your son may decide to keep digging into programming.


👤 ramphastidae
What got me into coding as a kid was modding games that I was already playing. Changing variables in GORILLA.BAS so they threw bananas at a faster speed. Messing with sprite files in Command and Conquer so I could design my own infantrymen. Anything where my changes gave me instant feedback was exhilarating. I think Minecraft and Roblox are the analogs today.

👤 marttt
I've been thinking about starting with Computer Science Unplugged when our kids reach that age: https://www.csunplugged.org/en/

My idea is to keep children off screen addiction for as long as possible, whilst still teaching them the relevant mindset, patterns of reasoning, and the way computers actually work.

On another angle, my son did start throwing together maps and sprites in no time with the (Lua-based) TIC-80 and Pico-8 when I showed these to him. Load81 by antirez is a similar Lua environment without the constraints: https://github.com/antirez/load81

Or, why not put together a low-cost computer/Z80-like terminal with your son, like the RC2014 that runs BASIC: https://rc2014.co.uk/

Good luck!


👤 syntheweave
A lot of people will say "teach concepts". Concepts are necessary, and learning languages like Scratch are good for revealing them.

On the other hand, reverse engineering is the "fast path" to grasp most any technical study in depth, programming included. Reversing only hits its limits when new fundamental concepts need to be introduced.

It doesn't have to be reversing from final results; studying and modifying pedagogical source code is fine and often better than "real-world" in the early going(since the real stuff is always cluttered with concepts). What you should teach in this regard is the technique you would use to study the code in depth: for example, how to "run a CPU" in your head, which can be demonstrated by stepping through with a debugger. Or using the printf statement to create a basic logging system. And the kinds of common data structures. If you give a kid an understanding of structs, arrays, strings, and event callbacks, and some rudimentary debugging knowledge, then point them at code to study, maybe with some guidance the first few times, they can self-learn a lot of things from there.


👤 seumars
I would definitely start with a block-based programming environment just to get started with general concepts like if-statements, loops, and whatnot.

👤 GoldenMonkey
You can’t really start with a coding language. Not knowing how to type is a blocker and discourages the kid… with formatting errors and compile errors that will happen. And the slowness of it all to get anything done… Learned this by experience with my kid.

Get the physical book - “25 Scratch 3 Games for Kids: A Playful Guide to Coding”. Graphical way to program. My eight year old was making games in minutes. And was ‘getting’ it.

Then, when a little older. Get a typing tutor app. Start them on python.

i.e. https://www.amazon.com/dp/1593279906


👤 iqster
Check our code.org. It feels backwards but I am very impressed. Move onto sphero , then micro-bit and then arduino. There are also decent systems called scratch jr and scratch. Finally, I can’t recommend LEGO mindstorms and boost enough.

👤 f0e4c2f7
I think python is the best way in. I was a few years older than that but not much when I started learning it.

It doesn't have very much syntax but you can still do stuff with it. A good place to start might be to find a library for something he likes. Maybe a game or some other topic he is into.

I've been using this video to teach someone. We watch for a while and then pause and code on my PC. I honestly don't know if it's a very good method or even a very good video. Results have been good so far though.

https://youtube.com/watch?v=rfscVS0vtbw


👤 jiripospisil
Get him started on something that focuses solely on the programming concepts and the way of thinking without any unnecessary noise (pointers, lifetimes etc.). When I was starting out I attended a programming club/group and we were using Robot Karel. It's a little programming environment where you control a robot and walk him through obstacles.

https://en.wikipedia.org/wiki/Karel_(programming_language)

https://karel1981.com/


👤 rg111
I would say that you must not think about programming itself. Programming what?- should be your approach.

He should be interested in something, and then should face some problem in it, and then be able to solve it with programming. Or use programming to make things better.

I don't think that you can make a 9 yo interested in outputting a bunch of text into console.

You can get started with Scratch, and see how things go.

Or you can introduce him to Minecraft where he can get started with Java to do stuff in the game.

You can also buy Osmo and check how that goes. Someone I know teaches her 3 yo using Osmo.

My personal choice would be to buy a Raspberry Pi kit with some sensors or an Arduino kit, and download and use Open Source prewritten code with those. Then tweak the code to do things. Then eventually write his own code to do stuff.

Another way would be to introduce him to text-based games like the ones in early-years of computing. There's a book around called- Land of Lisp, where Lisp is taught with Text-Based Games.

I would ask you to remember three things-

1. There would be a trial and error component to it. You will have to be willing to try different things to see what sticks.

2. Code with your son. I mean, give him a place, a desk, maybe, to sit beside you and code together.

3. A boring thing becomes interesting when there is chance to outsmart one's peers. An interesting thing will become more interesting this way. So, after initiation, try and enroll your son in a group activity involving programming.

I hope this helps.

There was a Google doodle some years back where "programming" was introduced. You should check this out and give your son this [0].

[0]: https://g.co/kgs/NbCoHY


👤 bjacobt
It maybe fun to do some simple hardware project and show him how coding works.

You could start with circuitpython since you know python. https://www.adafruit.com/product/4333

Adafruit has got good tutorials as well https://learn.adafruit.com/welcome-to-circuitpython

Here are few other suggestions https://news.ycombinator.com/item?id=29438050#29438836

If you run into any issues or like to bounce project ideas, feel free to contact me, my email is in my profile


👤 megumax
What's really important for a newcomer (and even more for a 9 year old) is to be motivating and rewarding. For most kids, modding their favorite game or drawing a few lines on a canvas would be fine.

The programming language doesn't matter, but lua for roblox or java for minecraft would be a good fit.

Background concepts like how does the CPU work, what's an OS, what's an architecture aren't important for a kid. If he wants to continue programming as a career, he can learn them, but they are not important to get started and will probably lose the motivation.


👤 derekja
I'm not a huge fan of scratch, generally. But I really like "machine learning for kids" by Dale lane. It is just a really nicely structured set of byte sized pieces on ai.

👤 myegorov
I've been going over Touretzky's Common Lisp book [1] with a 10-year old.

[1] https://www.cs.cmu.edu/~dst/LispBook/book.pdf


👤 aegis4244
Going through this now with a very bright group of 4 to 6 year old cousins. Code.org, then any blockly lang capable robot. $50-$150 on Amazon. Dash robot has has great and easy apps already written to use it. Great to get a 5 year old into it. 9 years old ? Go with the build it yourself dump truck and backhoe robot and save $100. Good luck

👤 LMMojo
Let him learn like so many kids from the 70s and 80s. By typing in programs from a book. Now in multiple languages.. https://blog.codinghorror.com/updating-the-single-most-influ...

👤 Bostonian
There is a company near me called KTByte https://www.ktbyte.com/classes that my son used to teach for. I see JavaBlocks mentioned for elementary school children.

👤 TheRealNGenius
There's this toy for the iPad. Don't remember what it's called at the moment. think it's called the Osmo. Seems like a good fit for children

👤 empressplay
Scratch -> Logo -> Python is a good way to go...

👤 taubek
Start with Python. Show him how to draw with turtle. This way you will introduce him to logical thinking, variables, conditions, graphics, etc.

👤 jimmyvalmer
Given its loosy-goosiness and ubiquity in gaming (Roblox), Lua is the inarguable answer.

👤 davidandgoliath
Pico-8 is what you absolutely should use. Tic-80 if you're on a tight budget.

ASAP!