This page was published over five years ago. Please be aware that due to the passage of time, the information provided on this page may be out of date or otherwise inaccurate, and any views or opinions expressed may no longer be relevant. Some technical elements such as audio-visual and interactive media may no longer work. For more detail, see our Archive and Deletion Policy.
In this collection of articles we aim to introduce you to:
- writing code to read in data from a user, perform some simple processing and display the result;
- programming for sequence, selection and repetition in a high-level language, specifically:
- how to achieve selective execution of sections of program code as a result of the evaluation of some condition;
- how to achieve repeated execution of a section of program code, either while a particular condition is true or for a specified number of times.
Although any standard browser will do, for our purposes we recommend Mozilla Firefox.
If you have not done so already, you should install both Firefox and Notepad++ before going on. If you are interested in learning in-depth about how to use Notepad++, you can visit the Notepad++ wiki.
If you are a Mac user, the text editor that comes with Mac OS X is TextEdit. Alternatively, a more powerful text editor is TextWrangler which can be downloaded for free, from here:
Speaking the Language
In programming, we use a formal language to communicate with a machine. If you don’t follow the rules of the language, known as its syntax, exactly, your program will not run or will not run as you expect. It can be a very frustrating experience to have to look for mistakes – usually called 'bugs'.
Please don’t be put off if you do make mistakes. Many people find that the process of making mistakes, and then working out why they are mistakes and correcting them, forms a very valuable – and even enjoyable – learning experience. You might find it helpful to keep a record of any mistake you make, and how it is corrected, for your future reference. You can think of the syntax of a language as its grammar. Programming languages also have vocabulary and meaning just like natural (spoken) languages.
As well as syntax, programming languages have reserved words, sometimes called keywords, i.e. words which have a special meaning in the particular programming language (you can think of the reserved words as constituting part of the vocabulary, or dictionary, for that language). Many programming languages use reserved words which look like English (such as while, for and if). But beware: the meaning of these words in the programming language might not exactly match their English equivalents. We shall explain the meaning (semantics) of these words in the programming language as we meet them.
We have provided working code for all the activities you'll be attempting, which, as a last resort, you may look at and run yourself. However, learning to program is a bit like learning to ride a bicycle: your learning will be extremely limited if you simply observe what other people have done. In order to really understand how to program, you have to write your own programs (albeit with a little help from us).
It can be an intensely satisfying, rewarding and creative experience to write a program which behaves in exactly the way you wish it to. It is now time to introduce you to this experience.
In this section, you will be writing some simple programs, which will enable you (or some other user) to input data via the mouse and keyboard, perform some simple processing on the data and then display the results of the processing.
Specifically, this section aims to:
- describe how to write a program to display information;
- discuss the concept of a programming variable;
- discuss the concept of data types, with reference to numbers and strings, together with some operations on them (arithmetical operations on numbers; concatenation of strings);
- describe how to use a dialogue box to obtain input into a program;
- discuss how to transform input data into numbers, where appropriate.
To get started, pick an article from the menu below. We recommend starting with 'Your First Program'.