What is a good example to show to a non-programmer to explain what programming "looks like"?

BASIC

10 PRINT "Sara is the best"
20 GOTO 10

Update: when I was 12, my cousin (he was 14) brought Turbo Pascal 7.0 and installed it in my computer.
He programmed a tic tac toe game from scratch (in BGI mode, for those who know).
I watched/observed step by step how a program evolves until it becomes a complete application.
Until then, I knew only how to print strings in BASIC :-B

You can do a similar thing. Pair programming. Well, actually your friend will be an observer but she'll get an idea ;)


Why not consider a language that doesn't exist (or does, if you so believe) and use Pseudo Code? I think, depending upon what you want to achieve - I'd consider the example of task familiar to the person, but carved up into a pseudo code example.

I generally find the idea of "cooking" or "recipes" to be a great fit when explaining things to non-programmers.

I ask the person to imagine they had a recipe that was fairly complex - e.g. a curry & rice dish. I then suggest that they should try and write it down for someone who has absolutely no idea what they are doing, so that they can cook it.

There is a very definite few stages involved:

  • Gather the ingredients and tools for the job.
  • Prepare the ingredients. This is complex. e.g.
    • get 3 Small Red Peppers.
    • for each red pepper you have, chop it into chunks about 1cm square.
    • place the red pepper chunks into a bowl for later.
  • Seperately to this, call the prepare rice function and have this working asynchronously in the background while you continue on with the cooking.

I'm sure you can see where this is going... ;)

There are a lot of similarities with Cooking and Programming (as there are with many things, but more people have an understanding of cooking than of building a house). There stages / similarities (as I see it) are:

  • Gathering: (declaration of what is required to achieve the goal and getting them together).
  • Preperation: Chopping the ingredients or readying the data connection objects etc for first use.
  • Asynchronous: The ability to have one thing going while another thing going.
  • Functions: The rice making, the chicken cooking and the curry cooking all require separate processes and only at the end can you have the makeCurry(chickenMeat, rice) function.
  • Testing: Ensure that as you are going along, you aren't missing any bits and that everything is going smoothly - e.g. ensuring chicken is cooked before you move to the next stage.
  • Garbage: Once you've done, you must ensure that you tidy up. ;)
  • Principals of Best Practice: There are efficient ways of doing things that like cooking, beginning programmers have to learn in addition to the code - sometimes it can be hard to get your head around. e.g. D.R.Y, how to chop efficiently with a knife & don't eat raw chicken ;)

Basically, I think for teaching programming as a general topic - I wouldn't necessarily teach from a language unless you had a compelling reason to do so. Instead, teach initially from the abstract until they understand at least the fundamentals of how things might fall together. Then they may find it easier when sat in front of a monitor and keyboard.

I think there may not be one "right answer" for this one. But I think maybe a few really good ideas you could maybe take bits from all of.


I would explain that programming is giving detailed instructions so the computer can make complex tasks.

How to make two cups of coffee?

  1. Fill the kettle
  2. Boil water

  3. Coffee in cup

  4. Pour on water
  5. Add sugar
  6. Add milk

  7. Do 3 to 6 again