What is Programming?
Learning Objectives
- Understand the difference between
programmatic thinking
andcoding
- Understand the strengths and weaknesses of computers compared to humans when completing a task
- Understand why the instructions we give to computers need to be different to the instructions we give to people
What is Programming?
Broadly speaking, when we talk about the activity of programming, what we mean is the act of writing a set of instructions that we can give to a computer to execute.
We can break this process down into two distinct processes, requiring different skills:
- The process of thinking up what instructions we want to give to the computer in order to accomplish our task
- The process of transferring those ideas into a written language that a computer can understand
The first of these we might call programmatic thinking. The second skill we might call coding, or writing code.
These are two separate (but related) skills, and to become a good developer we will need to get good at them both.
In this lesson we're going to look at programmatic thinking, and how it differs from normal thinking.
Humans vs Computers
At a high level, we can think of a computer simply as a machine that is designed to follow a set of instructions. It's what computers do, and it's the only thing that - by themselves - computers are good at.
Think about the last time you had to follow a set of instructions. Maybe you were playing some sheet music, baking a cake or building a flat-packed bookshelf.
Whatever the situation was, there was a similar relationship occurring to the one we see when a computer follows the instructions given to it in a computer program.
- You are acting as the computer - the instruction follower.
- The composer, the baker, or the furniture manufacturer are acting as the programmer - the instruction giver.
However, when it comes to following instructions, humans are better at some things, and computers are better at other things. The difference comes in the quality of the instructions given - humans are better at following bad instructions.
Humans are smart
Imagine you are baking a cake, and the recipe asks you to "add a splash of water to the mix".
As a human, you are equipped with sprinklings of experience, intelligence, creativity and common sense. You can cope with being given ambiguous, incomplete instructions like this. You can use your experience and common-sense to understand what the words "add to the mix" means, and decide how much is meant by "a splash", and successfully make a cake. This might be what we mean by "normal thinking". But to a computer, this vagueness simply would not work.
The instructions we give to a computer need to be both precise and complete. We would have to tell the computer where to get the water from, where to get the jug from, how to put the water into the jug, precisely how much water to take, and how to transfer it from the jug to the mixing bowl. Things that as a human, you probably wouldn't even consciously think about, and don't need to be told.
Humans are human
Now imagine you gave the same cake recipe to ten different people and asked them to bake you a cake. Because of differing levels of aptitude, experience and creative flair, you would probably end up with 10 different cakes. If you then asked the group to bake you a second cake, you would end up with another 7 different cakes, and 3 people who got bored, didn't finish the task and ate one of the first cakes instead.
But while on one hand computers require a much more complete set of instructions to complete a task, on the other hand they are really very good at following their instructions consistently and accurately. Much better than people are.
Given sufficient instructions, 10 computers would bake the exactly same cake as each other, and each computer would happily make 10 cakes, 100 cakes, A BILLION CAKES. Each new cake would be the same as the last. And each one would be the exact cake you asked for.
The trick is knowing how to write the sort of instructions that a computer can follow to complete a complicated task. This of course requires knowing a programming language, but also requires an understanding of the sort of data and instructions that a computer can follow, and the sorts of things that computers can do. This set of building blocks are at the core of all programming languages, and thinking in these terms is what we mean by programmatic thinking.
In the next lesson, we'll start taking a look at programming languages - what they are, how they are similar, how they might differ, and we will start using them to tell a computer how to do amazing things.