Why learn to program?

February 2015

Firstly, let's stop calling it "coding". The term is likely to put people off even trying to program because it implies that the activity is much more complicated and technical than it really is.

Anyone who has planned a dinner for a group of friends and has written down the steps for preparing the food, in the necessary order so that each course is ready at a suitable time, has already written something which is more complicated than many computer programs. Certainly a beginner's program will not involve the synchronising element, for a start.

The essence of programming is simply determining the right sequence of steps to make a process happen, to produce certain results. It involves logical thought about what the computer (or cook, in the example above) is capable of doing and how to make it do it in an efficient way. Learning to think in such ways is beneficial for doing anything that involves a logical sequence of steps. Business processes are a suitable application of the method but it can usefully be applied to many other things in life. Therefore it is a useful skill for everyone to acquire.

In the early days of electronic computing, around the 1950s, it certainly was necessary to use quite cryptic detailed instructions to make computers do anything. But it was very quickly realised that the machines themselves could translate programs written in terms that are much easier for humans to understand, much more like spoken languages. So the need for really writing in "code" is long behind us. The steps in a program today would be instructions like "read a line of text from a file" or "find a phrase within a chunk of text". In the early days those would have had to be broken down into the minutest details but today the system within which a programmer works will have a library of commands that achieve these kind of effects as single steps. Usually a programming system will suggest options as you start to type, so that each step of writing a program amounts to little more than selecting from a list of things that could come next. The skill is in knowing which sequence of steps will reliably achieve what is required from the program.

So, yes, there are programming languages to be learnt. But each is extremely simple compared to any spoken language. For a start, the vocabulary will be at most a few dozen words, rather than tens of thousands. The rules for combining the words (the syntax of the language) must be adhered to strictly, or the computer will not be able to run the program. But here again, the machine can help. It will provide a message when it encounters wrong syntax and the message will usually tell you exactly what is wrong. Learning a programming language helps in understanding the role of grammar (syntax and semantics) in any language and so learning to program can be useful for would-be linguists.

One difficulty is that there is now a very large number of programming languages available, so choosing one to start learning is not so easy. Teachers are faced with this problem and it has been made worse by well-meaning people inventing further languages in an attempt to create something which they believe is easier for beginners. I think there is no need because, as I have said, learning a programming language is very much simpler than learning a spoken language anyway.

The language I recommend for beginners is JavaScript. It works in all web browsers, running on anything from smart phones to large computers and so beginners' programs written in this language can run on just about any system. JavaScript only requires a simple text editor to begin writing with. So there is no cost for additional equipment before you can start. JavaScript has some features which are not typical of many programming languages but it does enable beginners to get into useful habits, such as object-oriented programming, to prepare for tackling larger projects. You can read an introduction to JavaScript here.

The difficulty with large projects, in programming as in other fields, lies in being able to see the overall structure as well as the detail. This is where good design is essential. There is a golden rule for all programming: Keep It Simple. This is often stated as the abbreviation KISS, which really stands for "Keep It Simple, Stupid". Programs often have to be enhanced and maintained (fixing bugs) at a later date. Unless the program is written as clearly and simply as possible, maintenance becomes expensive. So again there are useful skills to be learnt that can be applied elsewhere. Most writers want to convey their message as clearly and concisely as possible.

Programming can be a highly creative activity. Computers these days have high quality graphical and sound output which artists can exploit in numerous ways, extended by going beyond the standard tools available. By connecting other devices, either for input or output, the possibilities are limited only by our imagination and I am sure that so far we have only scratched the artistic surface.

Next page