Thomas the loop engine: Learning to program computers with a toy train

With the increased demand for computer programming skills in industries outside of technology, younger and younger kids are now taught the basics of computer science to prepare for future jobs. For example, when Amazon launched a program aiming to teach 10 million kids a year to code last week, it was because the company was “pretty confident that knowing how to code will be as important as knowing how to read for the jobs of the future.” The kids targeted by the Amazon program are as young 5 years old and the youngest group will be taught using online lessons and camps.

But what’s the best way to teach kids computer science basics, and are there ways to do it that don’t increase kids’ screen time? There is a large socio-economic gap in screen time, with minority and disadvantaged kids spending more time engaged with screens (see also). These are the same kids who are targeted by the Amazon program offering free online coding lessons. Meanwhile, some of Silicon Valley’s elites are banning screen time for their kids altogether.

A recent article in the Psychonomic Society’s journal Memory and Cognition suggests there may be ways for kids to grasp the basics of computer programming without ever touching a screen.

In this article, researchers Monica Bucciarelli and colleagues focused on kids’ understanding of action loops. Creating loops is a basic skill introduced early when learning to code since it allows you to easily repeat the same process over and over. For example, if you wanted to add an integer to each of a list of numbers, you could create a loop to cycle through the numbers and add the integer to each one.

Are there ways to teach basic topics in computer science, like looping, outside the context of a programming language?

There are lots of looping algorithms that don’t involve any programming. For example, when following a recipe, such as Nigel Slater’s recipe for the perfect olive and parsley focaccia, you may be instructed to “keep kneading until the dough no longer sticks to the board,” or “put the dough into a floured bowl and set aside, covered with clingfilm or a clean tea towel, until it has risen to double its size.” In these cases, you are instructed to repeat or continue a physical action until some event indicates an end to the loop.

Adults who have no experience with computer programming can deduce outcomes of looping algorithms and create their own. In two experiments, Bucciarelli and colleagues tested whether 10-11-year-old kids could also grasp this skill in contexts that don’t require knowledge of programming languages.

In Experiment 1, the researchers tested whether kids could predict the outcomes of looping algorithms without seeing them play out. In Experiment 2, they tested kids’ ability to come up with their own looping algorithms.

Here’s how the studies were conducted. Kids were shown a toy train set up on a track like the one pictured below, with a left segment, a siding track segment and a right track segment. The goal was to move the train cars from an initial arrangement on the left track segment to a final arrangement on the right track segment. The siding track was used to achieve the final arrangement.

 

 

For example, the train cars could be rearranged to a final arrangement reversed from the starting order (i.e., train cars A B C D E reversing to become E D C B A).

In Experiment 1, 30 kids were given verbal descriptions of an algorithm and asked what the outcome would be without acting it out. Half of the descriptions had a loop, and half did not. Here’s an example of an algorithm with a loop to reverse the train car order:

“Move one less than the number of cars to the siding.

While there are more than zero cars on the siding,

move one car to the right track,

move one car to the left track.

Three further iterations of the while loop yield:

Move one car to the right track.”

Kids were asked what the outcome of the algorithm would be, and their responses were categorized as “correct” or “incorrect”.

Kids were better at solving these problems than would be expected by chance. And those loops mattered. Kids had an easier time figuring out the consequences of algorithms that didn’t have loops (53% correct) than ones with loops (35% correct). Even so, over half of the kids could solve a reversal problem, which was the easiest kind, that included a loop.

In experiment 2, the researchers asked 35 kids to come up with their own algorithms to solve similar problems. This experiment also tested whether it is more difficult for kids to come up with an algorithm to handle an indefinite number of elements (which requires using a loop) than a knowable number of elements.

Half of the problems were about trains made up of six cars, and half were about trains made up of an indefinite number of cars (see the picture below), represented by cars emerging from a tunnel (kids were told that the tunnel hid many cars and “we do not know how many”.)

 

 

In this experiment, kids were shown an initial starting arrangement of cars on the left track and asked to come up with instructions to turn that arrangement into a pictured final “goal” arrangement on the right track.

In the six-car condition, they were asked to “try to tell me in words, without moving the cars, how would you form this train [in the picture].” In the indefinite-number condition, they were told, “because we do not know how many cars there are in this train, we need rules that summarize the moves to form the train in the picture.”

Kids’ video-recorded responses describing the solutions were watched by two judges and categorized as containing or not containing a loop, and were again categorized as “correct” or “not correct”.

Over 60% of the kids (22 out of 35) came up with a solution that contained a loop of operations for the train cars for at least one problem.

The number of cars mattered for success. Kids were more accurate at coming up with algorithms for six cars (66% correct) than an indefinite number of cars (15% correct), suggesting it’s harder to reason about an indefinite number of elements.

Does gender matter?

Even though computer programming has a female past, women currently make up less than a quarter of tech roles at companies like Apple, Google, Intel, Microsoft, Twitter, and Facebook.

Is there some hint of a gender difference in understanding computer science basics even before kids start programming?

No, across the two experiments the researchers found no differences in performance between boys and girls. In experiment 1, girls were at 38% correct, while boys were at 50% correct. In experiment 2 the qualitative pattern reversed, with girls at 44% correct, and boys at 37% correct.

There are likely many contributors to the tech gender gap, but it doesn’t start with a difference in understanding looping algorithms among fifth graders.

From train cars to code

This set of findings demonstrates that outside of a computer programming context, fifth graders (10-11 year olds) can understand looping algorithms and even come up with their own.

How can this finding be applied to teach computer programming?

It may be that kids could start learning about looping algorithms, as well as other computer science basics, in the physical world before moving on to learn about them in the context of a programming language. There are looping algorithms that we use frequently, such as in cooking and other physical domains, that may allow kids to learn valuable skills without upping screen time.

Real world experience may provide the building blocks kids need to program non-physical systems. First, train cars and recipes, next, code.

Psychonomics article highlighted in this blogpost:

Bucciarelli, M., Mackiewicz, R., Khemlani, S. S., & Johnson-Laird, P. N. (2018). Simulation in children’s conscious recursive reasoning. Memory & Cognition. DOI: 10.3758/s13421-018-0838-0.

The Psychonomic Society (Society) is providing information in the Featured Content section of its website as a benefit and service in furtherance of the Society’s nonprofit and tax-exempt status. The Society does not exert editorial control over such materials, and any opinions expressed in the Featured Content articles are solely those of the individual authors and do not necessarily reflect the opinions or policies of the Society. The Society does not guarantee the accuracy of the content contained in the Featured Content portion of the website and specifically disclaims any and all liability for any claims or damages that result from reliance on such content by third parties.

You may also like