PROGRAMMING: LANGUAGES AND STYLE
PROGRAMMING AND COURSEWORK
GCSE candidates are expected to be able to use computers to solve problems. In many cases this does not mean you have to be able to program.
If you are not doing any programming in your coursework then ask your teacher for advice about this unit. It may only be necessary for you to study part of it.
PROGRAMS
A computer works by carrying out a program of instructions stored in its main store. To do this it fetches and then executes machine code instructions quickly one after another. (Machine code instructions are dealt with in other topic ).
It is not practical for programmers to write their programs in machine code. Instead instructions are usually written in a language which is easy to understand. This language then has to be translated because the computer can only execute machine code instructions. This is done using another program-which may be an assembler, a compiler or an interpreter.
A source program is a program in the form originally written by the programmer.
An object program is the machine code program which results when a source program is translated.
PROGRAMMING LANGUAGES
A low level programming language is a computer language which is based on the machine code of the computer being used.
For a low level language:
1 Each instruction usually translates into one machine code instruction.
2 The fixed words of the language stand for machine code functions.
Examples of low level languages include: 6502 Assember and 80186 Assembler.
A high level programming language is a computer language which is based on the problems being solved. It does not depend so much on the computer being used. (Unfortunately some high level languages have so many different versions that they do depend on the computer used, e.g. BASIC.)
For a high level language:
1 Each instruction usually translates into a number of machine code instructions.
2 the fixed words of the language are words that the person programming uses normally such as technical terms in their job or just plain English.
Examples of high level languages include: BASIC, COMAL and Pascal.
Comparison of high and low level languages
Advantages of high level over low level
1 High level programs are easier to write.
2 They are also easier to understand and to modify.
3 High level programs are portable. A portable program is one which can be run on a number of different types of computer with only minor changes.
Advantages of low level over high level
1 A low level program is efficient. If a high level program and a low level program are written to do the same thing:
(a) The low level program will run faster.
(b) When the two programs are translated into machine code the high level program will use more store than the low level one.
2 Low level programs make full use of the computer’s capabilities. A high level language program written to run on any computer will not allow for the special features of a particular one .
Choice of level
Applications programs are normally written in a high level language unless there is an important reason for writing them at low level.
Programs are normally written at low level when efficient use of store and high speed are essential, for example:
1 Systems programs such as a computer’s operating system .
2 Programs which are to be stored on ROM (e.g. a word processing program).
3 Interactive graphics programs such as computer games.
Worked question
Give an example of a program for a microcomputer:
1 Written in a high level language.
2 Written in a low level language.
In each case explain the reason for the choice of level.
1 One example for which a high level language would be used is an interactive program to help pupils to understand the formulae for connecting resistors together in physics. Using it the computer draws a circuit diagram and the pupil has to calculate the value of one resistor. If the pupil cannot do it, the computer gives some help.
This program would be written in a high level language because it does not have to be particularly fast in execution. Also it would be far simpler to write at high level and the teacher might well want to modify it to fit the teaching situation.
2 A low level example is 8 commercial word processing program. This must make it possible to produce, edit, store and output text.
It would be written at a low level because it has to be fast and efficient at carrying out operations such as inserting passages, or transferring them from one place in the text to another. Once sold it would not be modified and the sales would be great enough to justify the programming effort to produce it in a low level language.