As discussed in my ‘what is coding?’ blog, coding on a technical level is a type of computer programming that closely or exactly represents what happens at the lowest (machine) level. However, when most people talk about coding, they usually mean something at a higher, more human-readable level which could be anything from problem orientated languages like Java, C++ or PHP: Hypertext Preprocessor to mark-up languages like HTML and XML. On a technical level, HTML and XML are not by themselves programming, but that is splitting hairs.
Computer programming is a way of instructing electronic machines to perform tasks, solve problems and provide human interactivity. Your laptop or home PC is a slave device that must be told what to do or have default behaviours that are programmed in to it, or it will do nothing.
As a lecturer of mine pointed out, even the most sophisticated home computer or smart phone is actually no smarter than a washing machine. And as these wonderful devices need human instruction at some point, all computer errors must therefore be down to one or more humans.
If we consider an everyday task for a moment, this will give us an insight to what computer programming in essence is. Imagine that you are visited by three guests and naturally offer each of them a cup of tea. Assume that this is your kitchen layout:
So, out of your three guests, two would like tea and one would like coffee. The coffee drinker would like two sugars and no milk, and one of the tea drinkers would like one sugar, whilst the other would like no sugar. Neither tea drinker said anything about milk.
Just by reading and processing this scenario and looking at the floor plan of the kitchen above, you will already have worked out that there are not enough cups on the work surface to complete this task. You will have guessed where to obtain more cups. But do you require one or two more cups? If you’re having a drink with your guests, you’d need an extra two and if not then one. The clean cups are most likely to be in the cupboard, unless any are visible on the draining board next to the sink.
You would probably assume that both tea drinkers would like milk, but may clarify by asking your guests, and will know where to get that milk as it will most likely be in the fridge. You are able to identify which container has tea bags, sugar and coffee. And even though the teaspoons are not identified on the layout (and nor for that matter is the drawers that contain the teaspoons), you will know the most probable place to find them. It would also be safe to assume that it’s not a good idea to use a teaspoon that has been used for making a coffee in the tea without at least rinsing it first; to save time therefore, you may well get two teaspoons for this task.
The human mind is amazing. It is able to process information quickly to accurately carry out tasks and fill in any blanks on the fly, clarify anything ambiguous by asking pertinent questions, and processing the answers accurately. Computers cannot do this; each step will need to be logically ordered, broken down into small chunks and executed at the correct time and in the right order. It would be no good to instruct a computer to fill the kettle first as there may be sufficient water in the kettle. So if you were instructing a tea making computer to do this task, all of the boundaries and parameters would have to be clearly and accurately set before asking it to carry out the actual task.
This gives us a clue as to what computer programming is: in order to write a program to instruct a computer, tablet, smart phone or any other electronic device which may be programmed, you will need to think about each problem clearly, breaking them into something called methods (or occasionally referred to as functions). A typical computer program will be constructed of lots of these methods, and each will contain commands and statements to perform the operations required.