Generations of Programming Languages

advertisement
Generations of Programming Languages
In order to write a program a suitable programming language must be chosen. A program is a set of
instructions written in a particular programming language. Which when executed will produce a
solution to a given problem or perform a specified task. The main difference between an algorithm
and a program is that an algorithm can be written in informal language without having to follow
special rules whereas the program is written in a programming language and must follow all the
syntax rules of the language.
A program written in Pascal is referred to as a source program or source code, because Pascal is a
high level language. However computers are built to execute instructions written in what is called
machine language. In machine language everything is expressed in terms of the binary number
system – 1’s and 0’s. Machine language is considered a low level programming language.
Generations of programming languages
Many programming languages have been developed throughout the years. These languages are
classified into different generations.
First Generation
In the 1940’s and 1950’s programs written in the first generation language consist of a series of ones
and zeroes. Such programs are referred to as machine language programs. This language is the lowest
computer language. Machine language programs have instructions that are similar to the following
01010101
10011000
00101010
01110001
11110000
10010101
Machine language is considered a low- level programming language.
Characteristics of 1GL
 Fastest to execute because it is already in a language that the computer can understand
 Difficult to decipher
 Easy to make mistakes
 Time consuming and tedious to write
 Machine dependent
Advantages
 Machine language programs are the fastest programs when being executed
Disadvantages
 It is time consuming to write.
 It is easy to make a mistake because only 0’s and ones are used.
 Programs written for one type of computer cannot be used on another kind of computer. They
are machine dependent.
Second generation
Second generation language is called assembly language.
Assembly language programs use short codes or mnemonics to represent instructions e.g. ADD, SUB.
This was closely related to machine language but it allowed the programmer to use instruction codes as
described above and names for storage locations rather than strings of binary digits.
Assembly language codes came in the mid 1950's, the second generation of programming language like
AUTOCODER, SAP and SPS. Symbolic addresses allowed programmers to represent memory locations,
variables and instructions with names. Programmers now had the flexibility not to change the addresses
for new locations of variables whenever they are modified. This kind of programming is still considered
fast and to program in machine language required high knowledge of the CPU and machine's instruction
set. This also meant high hardware dependency and lack of portability. Assembly or machine code could
not run on different machines. Example, code written for the Intel® Processor family would look very
different for code written for the Motorola 68X00 series. To convert would mean changing a whole
length of code.
Advantages
 Assembly language programs are easier to write than machine language programs.
 Can be easily converted to machine code by a program called an assembler.
Drawbacks
 It was very tedious and error prone
 It forced the programmer to think in terms of the machine( the CPU and the amount of memory
and the instruction set) rather than in terms of the problem i.e. the programming language is
machine dependent
 Therefore a program written for one computer could not necessarily be run on another
computer
Characteristics of 2GL
 Easier to write than machine language
 Machine dependent
Third Generation programming languages
Throughout the early 1960's till 1980 saw the emergence of the third generation programming
languages. The third generation programming languages are known as high level languages. High level
languages are not machine dependent. The programmer does not have to think of the machine but can
concentrate on solving the problem. They use English -like statements and are therefore easier to write.
E.g. COBOL, FORTRAN, Pascal, Basic and C.
Characteristics of 3 GL
 It uses English –like statements
 It is not machine dependent
Disadvantage

is that they have to be converted into machine language.
Advantages

They provide support for ideas of abstraction so that programmers can concentrate on finding
the solution to the problem rapidly, rather than on low-level details of data representation.

Although the syntax between these languages were different but they shared similar constructs
and were more readable by programmers and users compared to assembly languages.

Third generation languages support procedural languages, which means that the program will
execute a sequence of instructions in a specific order.
Name
Purpose
COBOL
To solve business problems such as inventory
control accounts and any problems involving
processing large volumes of data. Business,
finance and administrative systems.
FORTRANIt was designed to allow easy
translation of math formulas into code.
To solve problems that involve complex
mathematics, scientific problems, and
engineering problems.
Pascal
To assist in the teaching of programming
concepts but can also be used for solving
business problems
Basic
To solve mathematical and business problems
C
To write operating system programs and
business software. It is a general purpose
language
Fourth Generation
Fourth generation languages are easier to write than any of the earlier generations. They are nonprocedural. In a nonprocedural language, users define only what they want the computer to do,
without supplying all the details of how something is to be done. They use English like
statements and are very user friendly. Often abbreviated 4GL, fourth-generation languages are
programming languages closer to human languages than typical high-level programming
languages. Most 4GLs are used to access databases. For example, a typical 4GL command is
FIND ALL RECORDS WHERE NAME IS "SMITH"
4GL, or "report generator language" are "application specific" languages, with built-in knowledge of an
application domain in the way that SQL has built-in knowledge of the relational database domain. The
term was invented by Jim Martin to refer to non-procedural high level languages built around database
systems. Fourth generation languages are close to natural language and were built with the concept that
certain applications could be generalized by adding limited programming ability to them. When given a
description of the data format and the report to generate, a 4GL system produces COBOL (or other 3GL)
code, that actually reads and processes the data and formats the results. Some examples of 4GL are:
database query language e.g. SQL; Focus, Metafont, PostScript, S, IDL-PV, WAVE, Gauss,
Mathematica, and data-stream languages such as AVS, APE, Iris Explorer. Microsoft Visual Basic,
Visual Fox Pro.
High-level computer language (such as IBM's Structured Query Language or SQL) that allows nonprogrammer users to write (usually short) programs to query databases and to generate custom reports.
Advantage: useful for generating reports and are user friendly
Disadvantage: Can become very wordy and they are slow
Characteristics of 4GL



Uses English like statements that are more user friendly
This reduces the time taken to write
They contain built in function wizards to assist the user in solving the problem
They fall into the following categories





Database query language -SQL
Report generators –Oracle
GUI creators – Visual basic
Screen painters and generators – oracle forms
Data manipulation, analysis and reporting languages - Focus
Fifth generation languages
The 1990's saw the developments of fifth generation languages like PROLOG. 5GL’s are used mainly in
artificial intelligence. 5GL’s are non procedural languages. Essentially 5Gl’s are 4GL’s with a knowledge
base. The main difference between 4GL’s and 5GL’s is that 4GL’s are designed to build specific
programs whereas 5GL’s are designed to make the computer solve the problem for you. The
programmer only needs to be concerned with the problem and the constraints or the conditions to
be met for that particular problem. All codes for the 5GL’s are automatically generated. It uses a
visual or graphical development interface to create a program that is usually compiled with a 3GL
compiler. Examples of 5GL’s are OPS5 (Official Production System), Prolog (Logical Programming)
and Mercury.
Advantages

Computers will be able to communicate in natural spoken language.
Disadvantages

Very complex to design, programmer must be highly trained
Exercise
1. What is a computer program?
2. Give three examples of high level languages and the kind of processing for which they were
designed.
3. Name two characteristics of Two of the following:
 Machine language
 Assembly language
 High level language
4. Low level languages programs are more difficult to write than high level language programs.
State two reasons for this.
5. State the programming language that is associated with:
a) Artificial intelligence
b) Business applications
c) Operating systems
d) Scientific problems
Download