6 tips for teaching kids to code
Programming is a creative activity that any kid can engage in. Your child might not care about writing data processing algorithms, but they might enjoy creating games, programming music, designing websites, or just playing around with code.
I've written several books to teach beginners of all ages how to code, and I know from experience that you don't need to consider yourself a techie or "good at math" to learn. In fact, kids often can learn to program faster than adults precisely because they don't know how "difficult" coding is supposed to be.
If you don't know how to code but would like to learn in order to teach your child, check out my latest Python book for beginners, Automate the Boring Stuff with Python, which you can read for free online.
如果你不会编写任何代码，但想通过学习来教你的孩子，看看我最新的Python图书《Automate the Boring Stuff with Python》，它适合初学者，你可以在网上免费阅读。
Whether you are a software developer or you have no programming background, here are six tips to help your child get started with programming:
1. Use Scratch for younger kids, Python for older kids.
1. Scratch 是为小孩子们准备的 , Python 则适合大孩子们。
MIT's Scratch is a free programming tool designed for kids that runs in any modern Web browser. Anyone can run it at https://scratch.mit.edu. Its visual style was influenced by the Logo program, a staple of programming classes for children of the '80s and '90s. But Scratch is much more than yet another Logo knockoff.
麻省理工学院的 Scratch 是一个为儿童设计的免费编程工具，可以运行在任何一个现代网页浏览器中。任何人都可以从 https://scratch.mit.edu 运行它。它的视觉风格受到 Logo 程序的影响，Logo 是一个为 80 和 90 年代儿童设计的主流编程课程。但是 Scratch 远不止是 Logo 的山寨版那么简单。
Kids between the ages of 8 and 13 will benefit from Scratch's simple graphical interface. Scratch's drag-and-drop code blocks snap together. Pieces of code that don't make computational sense won't fit together, making syntax errors literally impossible. Scratch is great for younger kids who haven't developed typing skills.
8 到 13 岁的孩子们将会受益于 Scratch 简单的图形界面。Scratch 可以通过拖拽代码块将它们拼在一起。不可计算的代码片段则无法组合，这样杜绝了字面上的语法错误。Scratch 对那些不会打字的小孩子们来说非常有用。
2. Show source code for actual programs. Don't just talk concepts at them.
Despite its intellectual reputation, programming is a hands-on skill that requires practice, more than just reading books. Python's interactive shell encourages experimentation to find out what instructions do.
尽管编程以智力著称，但它是个需要动手练习的技能，光靠看书可不行。Python 交互式 shell 命令行鼓励通过实践来发现指令的功用。
If you are tutoring your kids directly, writing code goes a long way compared to just talking concepts at them. Even after learning about variables, loops, and functions, sitting in front of a blank editor and starting a new program is intimidating. Sit with them and describe the code they should write line by line.
Or, if you are using online resources to share with your child, look for the source code to small games. Programs with less than a couple hundred lines of code work best.
The Scratch website automatically shares the source for all projects on its website. Encourage your kid to make modifications to the code and see how they change the final program.
3. Games are fun programming projects.
Programming video games is a common starting point for many young coders. Angry Birds, Minecraft, Flappy Bird, Five Nights at Freddy's, and other games are prime sources of inspiration. I've written a free book, Invent Your Own Computer Games with Python, which demonstrates coding concepts with the complete source code for several simple game projects (Tic Tac Toe, Hangman, etc.).
很多年轻程序员往往都是从编写视频游戏开始的。《愤怒的小鸟》、《Mincraft》、《Flappy Bird》、 《Five Nights at Freddy》，和其它的游戏都是灵感的源泉。 我写了本免费的书《Invent Your Own Computer Games with Python》，通过很多独立小游戏（Tic Tac Toe、Hangman 等）的完整源码，来展示编程的概念。
Be warned that games your kids love might not make great programming projects when they're just starting out. Many games require teams of developers, artists, and designers to put together. Games that require a lot of level-design and artwork can overwhelm beginners. It's much more satisfying to complete a simple game, than to start and never finishing a massive project.
Refer to my list of 49 small games with simple play mechanics for practice ideas.
Even though games are fun, I generally recommend against dedicated "game creation" or "game maker" software. Like Scratch, these apps often try to present simplified programming environments. But unlike Scratch, they tend to water down the programming aspects. Programming with them tends to become more like configuring pre-existing software.
尽管游戏是有趣的，我一般不推荐“游戏制造器”或“游戏生成器”之类的专用软件。和 Scratch 类似的是，这些应用通常试图提供简化的编程环境。但是和 Scratch不同的是，它们会冲淡编程的概念。使用这些工具做编程感觉像在配置一个已有的软件。
4. Keep your hands off the keyboard and mouse.
Sharing knowledge is exciting. Showing someone what you know about programming is great. But coding is a skill that is learned with hands-on practice, so let the kids drive. Avoid jumping in to type on the keyboard when working with kids, even temporarily. If they have to click on a menu or button, point to the screen with your finger instead of taking the mouse and clicking it yourself. Whenever there is code to be typed, have them type it. It may be faster if you did it yourself, but your pupil needs the practice more than you.
5. If teaching a class, give each kid their own computer.
If you are teaching a group, try to give each student their own computer. Like playing a musical instrument, programming is a skill that is learned with hands-on practice rather than watching someone else.
The Raspberry Pi is a cheap, bare-bones PC that that runs about US$ 70 for a starter kit. Although adding a new keyboard, mouse, and monitor raises the total price to be comparable with a cheap laptop. Avoid Chromebooks, iPads, and tablets because; getting Python to run on them is difficult.
树莓派是一台便宜的准个人电脑，仅需要 70 美元。尽管添加新键盘、鼠标和显示器后，总价格和一个便宜的笔记本电脑接近。不要使用 Chromebooks、iPads 和平板电脑，因为 Python 很难运行在这些设备上。
If you need to set up a computer lab for an afterschool club on a budget, the Raspberry Pi would allow you to make use of spare keyboards and monitors. (See the Raspberry Pi Foundation site and Ben Nuttall's monthly Opensource.com Raspberry Pi column for free resources.) Otherwise, I recommend the cheap laptop approach, especially if you don't have a dedicated space and need to store the computers after class. Laptops have fewer cables to deal with and store easier.
如果你要为课外小组建立一个电脑实验室，并希望节省费用，你通过树莓派和一些闲置的键盘和显示器，就能够达到目的。（通过 树莓派官网和 Ben Nuttall 每月一次的 树莓派专栏 寻找免费资源。）另一个推荐是使用便宜的笔记本电脑，尤其是当你没有专门的场地，并且需要在课后把电脑存起来。笔记本电脑只用很少的线，存放起来更容易。
If individual computers aren't possible, kids can pair up and take turns. Remember Tip #4: Teach them from the start to ask their partner for the keyboard and mouse instead of just grabbing them away.
如果做不到每人一台电脑，可以让孩子们结对轮换。记住第 4 个建议：一开始就告诉他们要征求同伴的同意后再使用鼠标和键盘，而不是把同伴推开。
Some kids may be boastful and eager to dominate the machine, and less-confident kids will gladly let them have it. Have one kid be A and the other B. At points during the lesson, explicitly tell the group to switch seats so that A (or B) is in front of the keyboard and mouse equally.
有些孩子可能比较霸道喜欢独自占有机器，不够自信的孩子又愿意让他们占据。把一个小孩设定为 甲，另一个孩子设定为乙，明确告诉小组换位置，这样可以确保甲（或者 乙）公平的使用键盘和鼠标。
6. Skip the computer science.
If you are a software developer, you might be eager to share your technical arcana. Explaining recursive flood fill algorithms or practicing problems from Project Euler (a great practice problem site for those who want to sharpen their coding skills) is a lot of fun. Being dumped in the deep end is not so fun on the learner's end. Some topics you'll want to hold off on at the start:
如果你是一位软件工程师，会常常希望分享编程秘诀。讲解递归泛红填充算法，或者解决来自 Euler Project（一个编程实践问答网站，用户群是那些想提高编程技巧的童鞋）的编程问题充满乐趣。但让初学者一上来就接触这种难题，就不那么有趣了。你在分享下面这些主题前，要三思而后行：
Data structures besides lists/arrays and dictionaries/hash maps (linked-lists, binary trees, etc)
Networking protocols (beyond simple HTTP requests)
SQL databases, or other Domain-Specific Languages
除了lists、arrays 和 dictionaries、hash maps 以外的数据结构（例如：linked-lists、binary trees 等）
网络协议（除简单的 HTTP 请求以外的协议）
A good rule of thumb: If it's the sort of question that would appear in an interview at Google, skipping it might be better. When starting, covering a wide range of topics is better than going deep into technical details. Let your kids find their own passion. Once your child samples what the programming world has to offer, they'll be excited to explore the parts they like.
一个好方法：如果某些问题出现在 Google 的面试题中，最好跳过它们。开始阶段，涉猎广泛的主题好过深入技术细节。让你的孩子自己发现他们的兴趣所在。一旦孩子们尝试了编程世界提供的各种可能，他们会非常高兴探索自己喜欢的那部分。