Teaching programming to children and teachers

(Stefan Åstrand) #1

I am by no means a rockstar programmer but I have heard on many occasions that I do have an ability to explain complicated matters in simple and easy to understand terms. In order to grow as developer (and as a person) I have decided to take some time off the evenings and setup an introductory course in programming (with Javascript). The school I was talking to was very enthusiastic. Apparently, as of next year, programming will be included in the curriculum for all schools across Sweden. They offered me the opportunity to introduce it to children and their teachers, which is a very interesting challenge.

I am contemplating how to approach this problem conceptually. There are plenty of resources available for anyone who want to familiarize themselves in this subject, but in my opinion many of them becomes way too technical way too fast, or overly abstract and simplified. Programming in itself is a process of dealing with problems on a very detailed and technical level, as well taking a step back and looking at the bigger picture. I think that teaching programming should go along with teaching this skill.

I remember that what worked for me in the beginning was to start approaching problems as a machine would; by deconstructing them into smaller pieces. We humans process most information with our intuitive unconscious mind, but as programmers we learn to treat seemingly mundane tasks as a series complicated instructions. This counterintuitive way of dealing with problems I believe is the first hurdle to overcome in learning to program.

It would be very interesting to learn what methods, language, problems, tasks, explanations, etc. that worked for you to understand complicated concepts such as variables, operators, control flow, data structures or abstraction (through functions or OOP)? It could be anything really.

FFF is a fantastic learning resource, so I hope it would be a good forum to post this kind of questions.

(Erik Noorland) #2

First of all you don’t have to be a rockstar developer to be able to teach others. For a lot of people, what we do seems magical. But it isn’t.

What helped me the most in learning when i got started is the why. Why a variable, why a for loop, why an if statement. The how is easy, the why makes people understand.

So there’s my two cents. :slight_smile:

(Mattias Petter Johansson) #3

I am extremely interested in this topic as well. It is extremely important that we start teaching children at a young age, for many reasons.

I don’t have any particular ideas, other than to observe the prior art that is made on the topic. Linda Liukas has fantastic material, and the Scratch (https://scratch.mit.edu/) community has a lot of material. Kodcentrum in sweden (that uses scratch for the curriculum) also has some really interesting material, in the form of Kodboken (https://www.kodboken.se/)

(Daniel Lee) #4

Here in the US, the better school systems have had programming in their curriculum for quite some time; initially as elective and now as compulsory. I understand that Python is commonly used as a starter language.

(Pedro Martins) #5

Quoting Richard Feynman:

If you cant explain a concept to a layman, you don’t understand it well enough.

Before attempting to do anything here is the recommended path:

1 - Define what you want to teach, what concepts
2 - Understand those concepts to the deepest level
3 - Understand the Why of the concepts

Important to notice that to successfly follow through this 3 steps, you need to use “divide and conquer” recursively.

Once this is done:
1 - Identify target audience
2 - Identify analogies and common references amongst the target audiences
3 - Build a link between your concepts and those analogies

Explaining something is mainly an empathetic job: You need to put yourself in the other person’s mind and skin and follow from there.

I had the great pleasure of working alongside Linda Liukas when we were both in Codecademy ( a small startup back then ). She left to publish her book on to teach kids how to code in Ruby. I still recommend her work, if anything as a starting point.

(Stefan Åstrand) #6

Alright, a lot of good feedback. I will for sure look into the concepts and resources suggested. Thanks!

I believe analogies are useful in introducing new concepts and one such analogy I am particularly found of is viewing code as recipes for the computer.

A recipe conventionally is written in two parts: 1) a declaration of ingredients, and 2) a set of instructions. Similarly, in computer programming we have variables (properties), and methods (functions, procedures, etc.).

For example:



  • 2 cups white flour
  • 1 tablespoon baking powder
  • 1/2 teaspoon salt


  1. Preheat the oven to 375°F.
  2. Butter muffin pans.
  3. Mix the flour, baking powder, salt, and sugar in a large bowl.

Could (with some mental stretch) also be expressed in code:

class Muffin {
   constructor(servings) {
     this.whiteFlour = servings * 2 // of type 'cup'
     this.bakingPowder = servings * 1 // of type 'tablespoon'
     this.salt = servings * .5 // of type 'teaspoon'
   preheatOven() { ... } // returns a preheated oven
   butterPan(butter) { ... } // returns a buttered pan
   mixInBowl(whiteFlour, bakingPowder, salt, ...) { ... } // returns a bowl of mixed ingredients

I also believe that data structures could be explained with analogies.

For a processor, data is nothing more then a set of states. The kind of symbolic meaning that we humans assign to it is not anything a computer really is concerned with.

For example:

0000 0011

Could both represent the decimal 3 or the color of blue. Both are equally as valid, but we will interpreted them differently depending on how they are applied. Similarly the letter:


Could both represent a letter and numeral, just as the statement fancy pants could be a complement as well as an inslut.

Computers (like some people) have no processing unit for sarcasm, so you have to be very specific in which way the data it’s receiving should be interpreted. It will process both 1 + 1 and 1 + panda as equally valid because it doesn’t regard numbers and animals as separate entities.

Types give context to data so that the processor produce results that are consistent with how humans experience things, like that animals increment by breeding and numbers by subtraction. Data structures brings meaning to data which would otherwise been lost.

(Vallis) #7

Analogy definitely sounds like a good teaching tool. I think your jump from a written recipe to a class, functions, variables, etc is likely to be way too much for most beginners.

What sort of age group are you going to be working with?

Today’s Google Doodle is all about teaching coding concepts to kids. It’s a nice little game that deals (mostly) with the concept of loops. I think it’s based on Scratch.

Maybe considering the very basic concepts and building them up one by one would work for you?

(Vladimir Zdenek) #8

Personally I would stay away from OOP when explaining the basics. There is nothing that will help you explain basic stuff to laymen using OOP. OOP abstracts a lot of logic that only obfuscates the code unless you understand that logic behind certain keywords and commands. Having to first explain encapsulation, inheritance, etc. so you can start with “more interesting things” is not IMHO a very good idea.

(Chris Hughes) #9

I have always felt the concept of FeedBack is an under taught principle which contributes so greatly to the rudimentary understanding of complex systems.

I hope you may consider its place when designing a curriculum.

(Brian Sea) #10

I tend to scaffold students towards programming, concept-first. I get students to break problems down as they naturally would and then show them how to translate to a programming lanuage. Analogies and methophors work, but you’ll need to point out the flaws in them. For example, I hate the cooking analogy to programming, and I never use it, because it’s severely flawed (IMO). Actually, I use a similar exercise to demonstrate why we use designed programming languages versus a full-blown natural langauge.

Some warnings:

  1. Students will get frustrated, because they are trying to get computers to think like them versus changing perspective to meet the computer where it is. It takes them a little while to understand exactly how specific they need to get with instructions. For example, I forbid the use of pronouns in my classroom until students understand what is happening.
  2. You’re going to want to help students solve all the problems but know that helping them too much stymies their growth. If you do the problem solving for them, you rob them of an opportunity to figure it out themselves and for their brain to form neural connections. Let students know that this takes time. The more stress they put on themselves to longer it takes.
  3. If you use python or java, CodingBat.com is a resource for practice problems. For Javascript, their NodingBat, but it needs a lot of work.
  4. Start with non-computer exercises if you can. Students in my class don’t touch a computer for two weeks, because we’re doing non-computer computational exercises (Human Robot, Card sorting, Balloons, etc.)
  5. Have fun with it! If the students see you having fun, they’ll hang with it.

If you have specific questions, I can tell you what my experience says… but it’s mostly anecdotal (I’ve been teaching CS to middle/high school students for a decade).

Hope this helps,

(Matt Kjer) #11

At my workplace we have a program called Code Club - it uses a series of rather simple exercises that breaks down core concepts like loops, variables and logic in a visual (drag and drop) manner. It really focusses on teaching kids how to ‘think’ like a programmer.

The exercises are set out and documented in such a way that we have people, who don’t know how to program, able to comfortably pick up the tasks and help kids when they’re stuck. It’s a bit different from the angle you’re going for but you might find some inspiration in the exercises and format.


(Mattias Petter Johansson) #12

That is VERY interesting! Can you talk a little about why you think the cooking analogy is flawed, and why you think it’s still alluring for people to use as an analogy? Is it just because it’s common example of a set of instructions? Can you also talk a little bit about the exercise you use to demonstrate why we have programming languages?

(Mattias Petter Johansson) #13

Announcement: We are going to make this topic the Spotlight of the week! This means that it’s going to be moved to a public category, and featured on the youtube channel. If anyone objects to this for privacy reasons, we won’t do it, but it’s an amazing topic and we’d love to showcase it to the world.

(Brian Sea) #14

Can you talk a little about why you think the cooking analogy is flawed, and why you think it’s still alluring for people to use as an analogy?

I’ll address your questions in reverse. Educators like the analogy, because they feel that it is accessible to most students. The demonstrations are usually fun and comedic, and students remember them. Educators generally use the cooking analogy to demonstrate how to make a good algorithm, but I think it merely confuses students regarding levels of specificity (students get hyper specific and then have more trouble with abstraction). If anything, I would use it as an example of how not to create an algorithm. However, since lots of educators use it to demonstrate ‘good’ algorithms, I merely avoid the concept entirely.

Cooking ‘algorithms’ are quite often ambiguous to their intended audience (humans). Their pre- and post-conditions are (in general) ill-defined, and their timings and looping conditions are flexible or ambiguous (you often see phrases like “timings and temperatures may vary” or “stir until smooth”). Every bit of this is antithetical to the vocabulary and thinking we want students to move towards. The saving aspect of the cooking example is the definition of a pre-condition, post-condition, and, perhaps, why we don’t use a natural language for programming.

Can you also talk a little bit about the exercise you use to demonstrate why we have programming languages?

I use an exercise with balloons (if latex is prohibited, I use spheres). The goal of the exercise to demonstrate why natural languages are not “good enough” for humans let alone digital computers.

(0) Students are broken up into pairs. Each pair is given two balloons of the same color and one permanent ink pen (Sharpie).

(1) Students are told to blow their balloons up and tie them off so that the balloons are of “equal size.” At this point, students ask for clarification because of “ambiguity.” I simply tell them that they need to be the “same.” After all, the point of the exercise is show where ambiguity happens.

(2) Students are told to get back-to-back holding their balloons, and one person should be holding the pen. The person with the pen is Person 1, and the other is Person 2. (I harken back to this point later when talking about variables).

(3) Instruction: “Person 1 – Draw an X on your ballon.” Students ask for clarification, and I simply tell them to draw the X “however you wish.” I then tell Person 1 to hand the pen to Person 2. Students are to remain back-to-back.

(4) Instruction: “Person 2 – You are not allowed to make any noise, vibrate your body, or provide feedback. Person 1 – Without looking, verbally explain to Person 2 where to draw the X on their ballon so that the X is the same size, same boldness, and at the same angle as yours.”

I then repeat the exercise with Person 2 drawing an O, but Person 1 can provide feedback. Students are then asked to compare balloons (Spoiler Alert: They’re never the same). Students will claim that they’re “close,” but that’s not good enough. We then have a discussion about the words used. Common wording used:

( a ) “the top of the balloon” – What is the “top?” How did we agree on that?
( b ) “make the X the size of your pinky finger” – Because everyone has the same size pinky finger…
( c ) “make the O one inch (or centimeter) in diameter” – This one is fun, because students think they’re being smart by being hyper specific. However, when I get two students up to a board to draw a one-inch line, they are never equal (I don’t really care that they’re not one inch either).
( d ) “the line is very thin” – Really? How thin?

From here we have a discussion about measurements and common understandings. I point out that they could have used the pen cap as a measurement device, because it’s something that both sides have in common. Once students understand the need for specific words and common understanding, I turn to my second exercise, The Human Robot, to help with abstraction and computational thinking with a common vocabulary.

Note: I have done this exercise where I tell students ahead of time what we will do, and then give them two minutes to plan. The results are always the same (as in, the balloons are not).

Note 2: There are plenty of variations on this exercise. I have seen educators use random drawings where students write down instructions and another group attempts to follow them. This works well also, and I do this if I have time. However, in every case, the point is to demonstrate why natural languages (English in my case) are horrid for getting repeatable, specific algorithms.

I apologize for the length of this post, but I needed to be verbose to get my opinion solidified.

(Mattias Petter Johansson) #15

Oh my god @bsea, that is an amazing post! I think I’m pretty decent at teaching programming but you show me that there is still so much to learn about this. I love it!

(Mattias Petter Johansson) #16

The spotlight video for this thread is now live!

(André Matulionis Dos Santos) #17

Came here from the video. Amazing discussion. It even made me want to do a project of an Introduction to Programming course. Is there any material you people recommend to look for?

(Brian Sea) #18

It depends on your focus. Are you more interested in skills (programming) or the thinking?

(Pedro Martins) #19

Another good thread related to this one where I share some of my experience:


(Stephen Ball) #20

hiya all,
i signed up for this forum mainly because of this topic (i mean, i know some js and i love mpj’s videos, but this topic was what pushed me over the edge).
i’m a school teacher in the uk. i haven’t got any comp sci qualifications at all (all the computing knowledge i have is basically from places like funfunfunction), but i’ve been teaching kids a long time and i’ve done a couple of workshops to show simple computing teaching to teachers from schools in my area.
it’s really interesting to read @bsea’s posts - especially about not using recipes as an analogy. this is the kind of mistake i’d make all the time, even though i think i know what an algorithm is…
he also mentioned about about the difference between the thinking and the skills - i think that’s really important. for a lot of children and teachers, the thinking is going to be a lot more relevant, as those skills are more transferable.
these may not be suitable, or people may already know of them, but cs unplugged and barefoot CAS provide resources i use all the time. also code club projects have a great selection of resources, particularly using scratch, which kids LOVE (i’ve used loads of those).
i can’t believe i hadn’t seen linda liukas’ work before. thanks for that @mpj