Yes, I know that the title of this blog is the same as the title of Donald Knuth’s The Art of Computer Programming, and no, this is not a review of that book. In this blog entry, I try to argue for my view of computer programming as a creative process — more of an art than a science.
A computer program is a piece of code written to solve a specific problem. More often than not, that problem hasn’t been solved before — otherwise we could simply use existing software to solve it. So writing a computer program requires a programmer to come up with new algorithms to solve the problem at hand.
This is where the “art” part comes in. In order to write a computer program, you have to imagine the solution to a problem; your mind needs to come up with ways to express the solution of the problem in an algorithm that can be translated into computer code. Once this step is done, you can move on to the more mechanical task of actually converting your idea into a program written using a certain programming language and compiling your code to produce a final product.
That last step is important and non-trivial. You need to be familiar with the syntax of the programming language you choose to use. This familiarity will allow you to easily convert your algorithm into code. But the really creative part is actually coming up with an algorithm to solve the problem in the first place. It is this part of the process that I consider art.
Each art form has its tools; painters have their canvases, paints and brushes, musicians have their musical instruments and voices, and programmers have programming languages. We use programming languages to give “material” shape to the “art” that we envision.
At this point, an attentive reader may point out that there are many aspects of real-world problems that have already been solved. As a matter of fact, Donald Knuth’s book, alluded to in the beginning of this post, is a prime example of the wealth of solutions that have been developed to solve common programming problems.
Again, I consider these existing algorithms part of the tool-set that programmers use to create their art. A sorting algorithm, for example, cannot do anything by itself. You need to come up with an innovative framework that uses it to solve the problem you are tackling before it can become useful.
Some readers may be saying “so what?” at this point 🙂 Well, I am mainly writing this to document my thoughts about programming. But this also has broader implications — the most important being its effect on how we teach programming. So, how can you teach art? Is it possible for someone to take an untalented painter, teach him/her the rudiments of painting and then expect this person to produce a masterpiece?
Unfortunately this is not the case. At best, this person will be able to imitate existing paintings. The same applies, IMHO, to programming. You can teach the syntax of programming languages and you can show someone the thought process that you went through in order to come up with a certain algorithm. But you cannot teach creativity to someone who is not creative.
This is not to say that programming is fundamentally un-teachable. It is very “teachable” in the sense that you can teach someone the syntax of a programming language and the basic methodology of problem solving. But do not expect this person to create a Picasso — only a certain set of people will be able to take the programming language syntax and problem solving techniques they have been taught and expand on this to create truly innovative programs, the kind of programs that I refer to as “art” in this post.