Thursday, March 14, 2013

High Level Languages

High Level Languages

A program written in a high level language can be dealt with by a computer in two main ways. ( It can be translated into machine code by a compiler and then run.

A compiler is a program which translates a high level program into a machine code program.

There are two separate operations:

(a) Compiling the high level (source) program into machine code.

(b) Executing the machine code (object) program.

In fact once a program has been compiled and runs successfully, there is no need to keep compiling it. It can be run just by executing the object program. The source program will only be needed again if the program has to be changed.

2 The program can be run directly using an interpreter. An interpreter is a program which interprets a high level program, one line at a time, as it is being run.

Using the interpreter the computer recognizes each instruction. It then runs a machine code routine corresponding to that instruction.


1 To translate or interpret source code written in a high level language.

2 To detect errors in the program and print error messages.

3 To organize the storage of variables used by the program.

4 To link the program with any other software it uses.


This is shown in Figs 1 and 2.

Advantages of a compiler over an interpreter

1 Once a program is compiled, it can be used again and again without any further translation being necessary. With an interpreter the program is translated every time it is run.

2 Each line of a program has to be translated only once during a compilation, but an interpreter interprets a line each time it is executed. If a line is part of a loop it will be interpreted each time round the loop. Thus running a compiled program is normally faster than interpreting the source program.

Advantages of an interpreter over a compiler

When an interpreter is used, the source program is always in the store (sometimes in an abbreviated form). This means:

1 That the program can be changed easily if a run is unsatisfactory.

2 The version of the program which is in the store is relatively short-a high level program is generally shorter than its machine code equivalent.


An interpreter is used for interactive computing. High level programming on microcomputers

High Level Languages

High Level Languages 2

is often done with an interpreter, particularly if BASIC is used. High level programs on school or home computers are often interpreted.

A compiler is usually used when:

1 Programs are being batch processed

2 It is important that a program executes quickly. High level programs on large computers in business and industry are usually compiled.

Worked question

A compiler, an interpreter and an assembler are all programs. State what each of them has as input data. Your answer should make clear how these inputs differ.

For a compiler the input data is a complete high level source program. For an interpreter the input data consists of the lines of a high level program, taken one at a time in the order they are executed. The input data for an assembler is a low level source program.


There are very many different languages for various reasons.

1 Some languages are more suitable in particular programming situations. BASIC can be used for beginners using computers interactively. COBOL is good for commercial applications.

2 Some applications programs become so complicated that a new language is needed in order to use them-for example file enquiry packages (such as QUEST).

3 As new and improved languages are introduced, the old ones are still used. Often they are changed to fit the new ideas (for example, FORTRAN was improved in 1977).

Examples of general purpose high level languages

BASIC-Beginners All-purpose Symbolic Instruction Code

Purpose: Originally a teaching language for interactive work. Since extended.

Features: 1 Every line has to be numbered.

2 Easy for beginners to learn.

3 Difficult to write programs which are easily understood.

4 Many different versions.

COBOL-COmmon Business Orientated Language

Purpose: An easily understood. language for commercial data processing applications.

Features: 1 Statements look like English sentences.

2 Good facilities for file handling.

COMAL-COMmon Algorithmic Language

Purpose: Originally an extension of BASIC to allow a clear structure. It has since dropped some BASIC statements.

Features: 1 Every line is numbered as in BASIC. Numbers are just used for editing. They are not used for reference by program statements.

2 Extra words to allow structuring similar to those in Pascal.

FORTRAN -FORmula TRANslator (Produced in 1956- but still widely used.)

Purpose: For scientific use. Usually batch work.

Features: 1 Designed to be used with cards as input and a line printer as output.

2 Lack of statements which make program structure clear.

3 Some statements which are difficult for beginners to learn-e.g. FORMAT, which is used to define layout of input and output.


Purpose: An educational language to encourage logical thinking.

Features: 1 Enables the programmer to make a 'turtle' perform planned tasks. Originally a turtle was a device to run around on the floor, but it may be just a pointer on a screen.

2 New instructions can be defined and added in.

3 Facilities to process lists.


Purpose: To allow clear structuring of data and program.

Features: 1 All data (variables, etc.) have to be declared before they can be used.

2 Encourages clear structure and stepwise refinement.

3 New procedures, functions and data types can be defined and added in.


In some cases a high level language is only used for one particular type of application. It is Programming: languages and style

made up of words which are used in that type of application and is not suitable for other purposes.

Such languages may be used in various situations:

1 Making database enquiries or file enquiries.

2 Producing computer simulations.

3 Robot control.

There are many such languages.