Anyone can code

September 15, 2021

If I ever write a book on coding, it will be titled "Anyone can code" (if the title isn't already taken). I really do believe that anyone can code.

In the 2007, the Pixar animated movie Ratatouille in which the protagonist Remy, a rat, becomes a chef at a famous restaurant, there was a book written by a famous chef, Auguste Gusteau, titled "Anyone Can Cook".

Well if I ever write a book on coding, it will be titled "Anyone can code" (if the title isn't already taken). I really do believe that anyone can code. Why? What is coding? Coding is writing an algorithm in a language a computer can understand so it can be run on a computer. What is an algorithm? An algorithm is a set of instructions that accomplishes a specific task.

Believe it or not, we use algorithms every day, we just don't think of them much, if at all, and we don't call them algorithms. But when you reflect on it, there are so many "sets of instructions that accomplish a specific task" that we "execute" every day - from the time we wake up to the time we go to sleep. We have a set of instructions (albeit unwritten) for brushing our teeth, combing our hair, dressing, driving a car, eating, and the list goes on. All these everyday activities are algorithms. And we do them without effort or thought.

But what if we thought about it? What if we wanted to write an algorithm for brushing our teeth; what might that look like? Try it. Take a couple minutes and write the steps you take to brush your teeth.

Here's my teeth brushing algorithm:

  • Pickup toothbrush from holder
  • Wet toothbrush
  • Pickup toothpaste
  • Uncap toothpaste
  • Place a dollop of toothpaste on toothbrush
  • Recap toothpaste
  • Put down toothpaste
  • Open mouth
  • Brush teeth for 2 minutes - this is a whole sub algorithm on its own (in coding parlance this would be a function)
  • Rinse mouth
  • Rinse toothbrush
  • Put toothbrush back in holder

Is that similar to what you came up with? Did you write as much detail as I did or did you omit some of the steps? That's okay. One of the things you will learn as you move from everyday algorithms to coding algorithms is that you have to be very detailed as computers will do exactly what you tell them. As Ted Nelson puts it:

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do."

Give them an incorrect instruction, or an instruction out of sequence, and they will happily do it. Consider an algorithm (I mean a recipe) for baking a cake - what would happen if you beat the eggs before you before you crack them? The cake wouldn't turn out so well would it? Luckily with computer programs we can test them beforehand and try to identify any bugs (unintended results) and eliminate them in a process called debugging. That’s what you were doing as a baby and toddler. You were debugging the everyday algorithms until you could carry them out without thinking.

Coding is seen as a difficult skill to master but everything seems difficult until you learn how to do it. If you can do all these complex everyday algorithms then you can certainly write computer algorithms. You just need to learn a computer coding language so you can write the algorithms in a language a computer can execute. It requires thought, perseverance (as you will make mistakes), testing and correction (debugging) and practice, practice, practice. Start with simple programs. The first program I every wrote asked the user their name and then printed "Hello {{name}}". Work your way through more, and more, complex programs, and once you know how to code it will open up a world of possibilities.

We have a free course for parents and teachers aptly named "Learn coding for Parents and Teachers". Give it a try and see what you can create. You never know you might become bitten by the coding bug!