How to Learn Coding

Over the past months, some of my friends asked: how can I teach my children (or other younger relatives) how to code? What is the best programming language for them to learn? At what age should they start? etc.

I was a bit baffled, partly because I didn’t know where to start, partly because they didn’t explicitly say why the wanted to encourage their children to code. The general notion was “we believe it could be a key skill in future”.

TL;DR: This is lengthy article. The gist is: yes, it might be a good idea for children to learn coding. Focus on games. Head over to MIT Scratch, or to get started.

Whether ‘coding’ really is a relevant skill in the future is a tricky question. Perhaps AI takes over the dull job of programming at some point? Whatever it is, I think there are a number of relevant and not-too-hard-to-acquire skills which may prove valuable largely independent of the exact technological development, that can be roughly grouped under ‘coding’.

Also, it will help to understand (or motivate) maths a lot better, which is why I think it absolutely makes sense to give children some exposure to coding.


But let’s back off a bit. What would (basic) coding really teach you that could be practically relevant? I think there are three aspects:

  1. Understand the world around you. With the ubiquity of computing devices, mostly smart phones, having a rough idea of how and why these work can be a very de-mystifying and hence soothing piece of knowledge.
  2. Self-Service is increasing. For instance, a modern business intelligence department might supply you with the data itself and tools to analyze it where a traditional one would sit down with you to build a report. While these tools are becoming more powerful and accessible, the ability to write a quick R, Python or whatever script might be helpful in a growing number of roles.
  3. Perhaps more importantly, “talking to the eggheads” has become a key skill for many roles, including senior executives. Having a vague idea of what it is that engineers, data scientist etc. actually do will certainly help interfacing with them.

And indeed I believe the basics of programming will teach these, among other things. The key value of computers is their programmability. Coding brings you right in the middle of that. Nothing will give you a better and more profound understanding in the jungle of programmable technologies (aka computers), even if you don’t end up being a programmer.

Learning Principles#

Since coding is primarily a tool rather than a subject, I believe that active learning and playfulness are even more important than with many other topics.

But how do you teach using tools? The hardest part is to find problems that are engaging and challenging, yet solvable. Successfully solving a hard problem with a tool is what proves its value and makes it fun.

But don’t take my word for it:

What I cannot create, I do not understand Richard P. Feynman

What I cannot create, I do not understand

The way I read it is this: if you can’t apply the tools to known problems, you haven’t mastered the tools. Learn that before moving on to problems with unknown outcomes.

What Skills are Required for “Coding”, Anyway?#

“Coding” a website, a physics simulation and an ERP system have something in common, but it’s certainly not quite the same thing. They also require very different skills.

So really, what we need to do is twofold:

  1. Teach how to use the tools: printf("hello, world"); and the likes, aka basic programming or learning a programming language
  2. Show problems from different fields that children can understand, which can be solved with the tools they have been given

These two interact, and a lot of small iterations are important to understand each problem and explain the value of each tool, step-by-step.

Compare this to cooking (or baking). You’d say “here, you can help me crack some eggs to help bake this chocolate cake” to get started instead of giving a theoretical lecture about foaming, emulsification and coagulation of protein. Breaking eggs is hard enough for the start.

So, what we’re looking for is the cook who can choose the recipies and decide what tasks they’d give to the learner and which they’d take care of themselves for now, making a tasty pie (or chicken, or pasta…) to keep you motivated.

Learn the Tools#

Learning a programming language is clearly “coding”, but most coders would say that this is the easy part. There is a plethora of programming languages, but the languages themselves are much easier to learn than natural languages. Many languages, in fact, are designed with specific types of problems in mind that they can solve well. You wouldn’t learn French just because it sounds better in the kitchen, but it may make sense to use a specific programming language for a certain problem.

More profoundly, however, the ability to “codify” precise instructions and deal with strict logic is a skill all by itself. This will probably stand the test of time, because, as it turns out, making clear what you want, exactly, is really hard. For a playful real-world excercise without involving pen, paper or a computer, this might be fun to do:

In a way, this also demonstrates that the choice of programming language is much less relevant than many people believe by analogy to natural languages. It’s much less of investment than a natural language is, and easier to transfer those skills. Some people go so far as to say “know one and you know all”.1

Find the Problems#

So, back to the problems. How do we find enganging, interesting problems that children can understand? While you might be familiar with them, I guess the domains ERP, spreadsheet tools and word processors won’t really engage most children.

What really nudged me into programming was a saying that I didn’t quite understand: “All a computer can do is compute ones and zeros”. That baffled me, because my experience with computers was that they were fun, whereas ones and zeros sound boring.

If all a computer can do is add ones and zeros, how can I play TestDrive on my C64 2?

TestDrive on a C64

I believe computer games are very motivating and should be the focus of the teaching effort. Aside from programming, making games also offers a lot of other interesting challenges, from visual design through storytelling and sound design. On the programming side, they offer ‘real’ problems from almost any field of computer science and maths. However, that can also be a curse, because a lot of seemingly simple problems can be surprisingly challenging.

Even moving around on a regular 2-dimensional grid based on mouse input as you would see in “The Sims” or “Age of Empires” isn’t as simple as it may seem. The very fact that the mouse position is reported as a 2-tuple or vector { x, y } and the fact that movement in one axis generally doesn’t affect the other (the principle of superposition) isn’t too intuitive or obvious.

But now, making a game has become the problem, and Maths and Coding are the tools to solve the problems that come up. This is great - the dull and seemingly arbitrary coordinate system from Algebra class suddenly has a real use case and helps to solve a problem (“how can I prevent the player from walking through walls?").

The kind of problem-solving required to even approach this is another key skill. Open problems like this seem largely removed from the school curriculum, as Dan Meyer brilliantly points out in his TED Talk:

Also, the computer gives you instant feedback. An incorrect implementation will simply not work (or worse, work only sometimes). That can be frustrating, but also engaging. This isn’t a teacher who’s trying to keep you off the wrong path here. A flaky implementation is the wrong path.

Online Courses#

So, we’re going to need the ‘cook’ that can help us navigate to the easier problems at first and then gradually add both new problems and new tools.

You can perhaps find local or remote instructors to do manual mentoring. That is great - if you want to go down that road, make sure the learning principles are met and show an interest in the problems (rather than merely the solutions).

But even an instructor would probably want to start out with the help of some of the environments I’m going to show, so it might be helpful to know them.

We need more patient problem solvers Dan Meyer

Let’s look at some of the available beginner’s courses:

Visual Programming Languages / “Block Coding”#

Block coding (or drag-and-drop coding) removes the need to type a lot of text and can remove a lot of unnecessary frustration for beginners. Typing code can be hard, because the typing alone isn’t easy. Code, or more specifically, keywords are also generally in English (for, if, while, etc.), which adds another layer of complexity if your mother tongue isn’t English.

A famous example of block coding is MIT Scratch. It is free, runs in the browser, comes with a bunch of resources and is targeted at kids age 8-16 (Hint: try it yourself!). To give you a better idea, it looks like this:


Scratch is also available in many (natural) languages, which extends to the programming language itself. So turn 15 degrees is shown as drehe dich um 15 Grad in German:


However, the tutorial videos are available only in English. There is also a version, ScratchJr targeted at ages 5-7.

Differences to “Real Code”

Scratch is a visual development environment. The code is ‘attached’ to sprites on the screen 3. So you drag a “sprite” on the screen, for instance a tiger. Then you can program its behaviour. Every sprite on the screen can be programmed, and the code blocks allow for very clever interactions. For example, a sprite can check whether it intersects with another sprite.

In ‘normal’ programming languages, you would have to keep a list of sprites on the screen. Your code would iterate the list with every frame and ask the sprite to think() (you could call that method what you like), updating its position and potentially checking with every other sprite 4. In a different part of the code, you would want the sprite to render(). Scratch takes all this complexity and bookkeeping away and lets you focus on the actual behavior instead.

To do so, Scratch comes with the idea that “sprites” always have a few basic physical properties such as position and orientation, which makes it very natural for 2d-games.

However, when you’re building something like pong in Scratch (pong is ultimately a simple physical simulation), you may quickly want to improve tons of things compared to the pong example that comes with it:

  • You may want to reflect the angle (physics tells us the inbound angle equals the outbound angle, rather than just turning the object by 180 degrees)
  • You might even want to give the ball angular momentum, even if you don’t know what that means (“spin”), let alone how to implement it
  • The collision detection easily breaks, because “collision” and “intersection” aren’t really the same thing

If these limitations start to become an issue, that’s probably good - we have sparked a lot of interest. However, it’s not necessary to jump to raw, native code just yet. When the limitations of Scratch get in the way, there are still small-step alternatives that offer more freedom.

Simple Game Development Frameworks#

Combining block-based (and also text-based) programming with existing frameworks can be fun, because it allows to create something that is more impressive without having to work through the basics just yet. Minecraft can be such an environment, for instance.

There are exciting courses on top of Scratch or based on similar concepts, often integrated with Minecraft or other visual environments. For example,

  • [free] Lots of resources for kids 4-18
  • Tynker [paid] Offers include Minecraft mods and visual programming

Markup Languages & HTML#

While markup languages are (in a debatable way) not ‘real’ programming languages, they can teach you a lot of important lessons. They might also serve well to prepare moving from block-based coding to text-based coding. All you need is a text editor and a browser, so you’re leaving the somewhat simplified, protected playground of block-based programming.’s WebLab

This is also a very natural way to introduce JavaScript, arguably the most common programming language for the user interface today.

Hands-On Simulations / Game Design#

Eventually, it makes sense to jump at more advanced topics, and, more importantly, less guidance. Moving to

  • Codakid offers courses in Scratch
  • Roblox, using professional programming languages (like JavaScript) and game engines (like Unreal). Only available in English.


Errr… what? Yup. Excel. This you can probably show yourself.

Nothing too fancy, but one of the most valuable things I learnt in my school’s CS courses (the teacher and I had an agreement I’d keep out of it get an A+ in return) was the basics of Excel. I simply didn’t know what it was good for. A quick intro can be enough to show its usefulness. So make sure to show that Excel can do stuff like =B12+$C14 and =SUM(B1:B20). If they have shown some interest in the other items, they’ll figure out the rest of Excel by themselves.


For those with an interest in maths itself, I recommend the YouTube channel of 3blue1brown. For example, the series on Calculus:

The channel also explains some of the much more fancy mathematical areas such as the Borsuk-Ulam theorem or neural networks.

Advanced Topics#

Eventually, for those that really want to deepen their understanding, it makes sense to simply build a lot of stuff.

Build your own blockchain, raytracer, database, spreadsheet software and operating system. Surely, production-level products of these types typically contain tens of thousands of person years of work, but the basics can often be learnt and implemented in a weekend. Even simply becoming aware of the problems that these things solve is valuable.

Limiting the Cognitive Load of Source Code#

Practical programming often revolves around structure: consider code was just a novel. But how can you write a novel with dozens, even hundreds of authors, making sure that it still has a certain “feeling”, and more importantly, doesn’t self-contradict? This is a completely separate challenge.

Any fool can write code that a computer can understand. Good programmers write code that humans can understand. Martin Fowler

Then again, someone who’s really interested in the matter will run into the problem all by themselves, which is a much more natural way to learn. Of course, there are many more aspects that production-level code will have to account for, such as security, privacy etc., but these ultimately are merely different problem areas that can be solved with the tools learned before.

  1. I’d contest that, because the idioms of a language aren’t necessarily easy to learn. If you have mastered C, you have no idea about functional programming or actor systems or object-orientation, necessarily. I do believe, however, that many people who have mastered even just one language have developed enough skills to learn different idioms quickly ↩︎

  2. I guess a bit of the mystery stems from the fact that the “coding” part is somewhat hidden from normal users these days. While it was never easier to learn, the direct interaction of the main computer UI is very detached. Tomas Petricek wrote a very interesting article on this, and in fact a great C64 game tutorial. Try it! ↩︎

  3. This concept was also present in Hypercard, an Apple tool that was discontinued in ‘98. To get an idea of this, ViperCard is a slightly modernized version, but I guess I wouldn’t suggest it for educational purposes because it’s a bit too retro. ↩︎

  4. You have now created an algorithm of $\mathcal{O}(n^2)$ complexity. Works for simple problems, but will bite you eventually, leading to a path of “why are data structures important, what are trees and how do databases work?”. ↩︎

comments powered by Disqus

© 2020