Teaching Non-programmers what Programming is Like

How do you comprehensibly explain to non-programmers the challenges of programming? Why can’t you “just tell the computer what you want it to do”?

A classic teaching tool for this is the “make me a peanut butter and jelly sandwich” demo.

Put out on the table a jar of peanut butter, a jar of jelly, a loaf of bread, and a knife. Tell them you are a robot (computer) that is physically capable of making a peanut butter and jelly sandwich, but you need instruction (programming). That’s their job.

If they say, “OK, put the peanut butter on the bread”… put the jar of peanut butter on top of the loaf of bread.

And so on.

In your supremely patient robot way, show them that while you make no inferences and have no common sense, you’re happy to follow specific instructions.

To get you to spread peanut butter on a slice of bread, they’ll learn they have to tell you to…

  • unscrew the top of the peanut butter jar and set it aside
  • open the bag the bread is in
  • pull out a slice of bread
  • pick up the knife (by the handle end!)
  • get peanut butter on the blade of the knife
  • spread the peanut butter on one side of the bread and leave it face up

Getting all the way to the end may be more than is needed (and more than you or they have patience for).

But once they’ve gotten the idea, you can explain that if they had guided you all the way to a complete sandwich, all the instructions they gave you to achieve that would amount to the first, alpha version of the program. A version which doesn’t yet account for things like what to do when you run out of peanut butter or jelly or bread, or what to do if the bread tears…

(Full disclosure: I have not taught this lesson yet myself!)