A magazine where the digital world meets the real world.
On the web
- Browse by date
- Browse by topic
- Enter the maze
- Get our RSS feed
- Follow us on Twitter
- Resources for teachers
What is cs4fn?
- About us
- Contact us
- Privacy and cookies
- Copyright and contributions
- Links to other fun sites
- Complete our questionnaire and get a free magic download
Programming is a core activity of computer science. It is a skill for creation. Once you can do it, the sky's the limit over what you can make computers do. A program is just a plan of action a machine can follow. From such plans comes everything the computers you see around you do.
So how do you write a plan of action? It has to be written in a precise language, so that there can be no confusion as to what is meant. Everyone has to agree about what any instruction does. Different programming languages have different kinds of actions you can use as basic. They also have different ways of putting them in order. If followed in the prescribed order they should get the job done. Without fail.
Programs are like ...
Programs are like recipes
The chef who writes them tries to write the instructions clearly enough that anyone can follow them. They tell you the actions (stir vigorously) and the order to do things. (no point baking first then, stirring vigorously). Recipe book languages are not precise enough though. My cakes still come out burnt or soggy. What exactly did "until firm" mean? We have to do better than cookery book writers.
Programs are like musical scores
When a composer writes a musical score they are doing something very similar to programming. Just as with programming complex notations have been developed for writing music. The actions are now just to play specific notes in a given order. Assuming the musician is skillful enough to follow the instructions in the score, the music will sound the same every time it is played. Mind you there is still room for interpretation. Great musicians go beyond the score, putting in feeling. The other thing about musical notation is that it is only a language for making music. Our noughts and crosses language was similarly only a language for writing noughts and crosses programs, nothing more. We want languages that allow us to write programs to do anything.
Programs as objects
There are lots of ways of thinking about programming. The different ways lead to different kinds of programming language. So far we have been thinking of programs as being sequences of actions to follow - a recipe. Another way of thinking of a program is as a description of lots of objects or agents that have behaviours (things they can each do) and properties (things about them that tell them apart). These objects send signals to each other to get things done they can't do alone or to tell another it is their turn.
We've looked at two different ways of thinking about programs above. Another way of thinking about them that is based more directly on mathematical reasoning gives a family of languages known as "functional programming languages".
If you want to try some functional programming visit the University of Oxford's GeomLab site. It is a great way to learn about this different style of programming by drawing pictures: even ones as complicated as Escher's beautiful, thought-provoking pictures with ever-repeating lizards, fish and other animals that you may have come across. You will also get an idea of the issues in laying out the elements of web pages like this one. Programs do that too.