Programming: why are we so fussy?

Programming needs to be very precise and accurate. Programming is all about telling a computer what to do. Computers are used nowadays for almost anything, including transferring of money between bank accounts, management of life-saving medical operations and the control of intercontinental balistic missiles. It's all very well saying a program "nearly worked" and hence that it is unreasonable to blame the programmer, but if the result is that the program fires a nuclear warhead at Birmingham instead of **** (insert the name of your favourite target) I suspect most people in Birmingham really would blame the programmer (if any of them survived).

So we need to tell the computer what to do at all times, and we need to get it right. One approach would be to give the computer instructions in English. But English is ambigous at the best of times. Consider,

These are structurally identical: <plural-noun> must be <verb>. The first means "if you have a dog you must carry it" and the second means "if you are on the site you must wear a safety hat". No computer program can distinguish these from "if you are on this escalator you must carry a dog" and "if you have a safety hat you must wear it".

The other problem with English is that people who speak it typically do not say what they mean. If a restaurant owner puts a sign up saying "People with beards and umbrellas will not be served" it is not at all ambiguous. But someone logical with a beard but no umbrella might get annoyed if they were not served. What the restaurant owner probably meant was, "People with beards or umbrellas will not be served".

So not only do we need a computer program that can decide what the thing we just said actually means, but we need one that can read our minds and decide what we should have said instead, and do so with unfailing accuracy to prevent anyone accidentally nuking Birmingham. No one has succeeded in writing such a computer program.

Instead, special computer languages are designed which are so precise that it is impossible to be unambiguous, and at all times the meaning of all phrases is completely predefined, but it's still up to the user to ensure that what says is what is needed.

What you are about to learn is how to program a computer accurately and unambiguously in the language C++. The language C++ is the subject of an international standard saying what the possible expressions are and what each expression in it means. I can't change that standard. (If I could, I probably would do so for the sake of beginners, because there are a lot of pitfalls in C++, but for professional programmers the standard as written is probably about right.)

So all I can do in these web pages is tell you what the various features of C++ that you will be using actually mean. It's your job to learn the details and use them correctly. I can't change those meanings. If you do get it wrong and accidentally nuke Birmingham (or the equivalent) in your own programs then you must take the consequences: there are unlikely to be any "part marks" or "follow though marks" even if by some good fortune Birmingham itself remains intact.