How do you teach programming to your kids?

Amit Patel on June 18, 2019

My elder son is in 6th grade and had Basic, Logo, kturtle, edubuntu in his curriculum so far. Last weekend he asked me to help him learning Ruby. ... [Read Full]
markdown guide
 

I've taught a couple of kids the basics of coding over the past 5 years, albeit using Python in each case (Ruby probably wouldn't be too bad, but I've got little to no experience with it).

First off, start small, and make a point to explain why you're starting small. I've usually used some kind of video-game analogy as part of the explanation (that end goal of writing a game or developing a web app is like the final boss of a video game, you can't realistically go fight it immediately after you start playing and expect to do well). A lot of people expect to go straight into the flashy stuff right off the bat, but get really disappointed when they start out just teaching a computer basic arithmetic. Making sure that the initial expectations are realistic helps people, and especially kids, stay focused long enough to get to the good stuff.

Beyond that, it's largely figuring out how to explain many of the core concepts to them. Some things I've found helpful regarding that:

  • Make sure you explain the concept of binary (ideally including basic arithmetic) before you try to explain the differences between integers and floats. Being able to show the kid the math (even if aggressively simplified) behind the unintuitive behavioral quirks of floats can in many cases make it a lot easier for them to understand the issues that come with using floats.
  • Cover functions early. Even most kids can get the concept of a function pretty intuitively, and functions make demonstrating many other things easier. Also, for any modern language where functions are just another type, explain that when you explain functions.
  • Wait to cover object-oriented or functional programming until you're sure they've got a rock-solid understanding of procedural programming. This helps ensure they don't get overwhelmed by the either concept. Also, don't try to declaim OOP or FP as a silver bullet that will solve all problems (more generically, try to avoid teaching your bias to your students).
  • Teach looping and recursion alongside each other. They're used to solve the same kinds of problems, and it's a lot easier for most people to understand the strengths and weaknesses of both if they're taught together.
  • The Thue-Morse sequence is an amazing tool for teaching programming. It's actually pretty intuitive to most people once it's been explained to them, there's literally dozens of ways you can go about computing it in most languages (with varying degrees of resource efficiency), and it's not trivial like the Fibonacci sequence is.
  • Make a point to use the REPL as a teaching tool. The rather immediate feedback it gives really helps people with short attention spans.
  • Make absolutely certain you cover the concept of types beyond just the basic 'this value is type A so you can do X, Y, and Z with it' stuff. Even with a dynamically typed language, it's important to understand that there's actual metadata associated with every value that tells the interpreter/compiler how to interact with it.
  • If at all possible, make sure to explain the reasoning behind good coding practices, and make a point to encourage them. Some of the old entries from the international obfuscated C coding concest are actually really good for this, even if you aren't teaching C.

And one last point, with a funny anecdote to go with it:

  • When teaching using an IDE, turn off pretty much all the bells and whistles at the beginning except syntax hilighting. Most of that extra stuff is great if you're an experienced coder, but when you're just starting out, it can be really overwhelming, or worse, make learn the IDE instead of the language. My favorite example of why this is important comes from the first CS course I ever took in college. It was a Java course that used NetBeans as the IDE, and the instructor actually taught the auto-completion mnemonics alongside the code they generated. When the first test came up, more than half the class failed because they used the auto-completion mnemonics instead of the actual code in questions that asked you to write down code to do something. Because of how the class was taught, many of the students had never actually typed the full function names into an editor before, so they had never actually learned them.
 

Thanks Austin for sharing your experience. It's quite useful especially "start small" is spot on.

code of conduct - report abuse