Chapter Two
Chapter Two
Chapter Objectives
By the end of this chapter the learner should be able to
Define a programming language
Describe the types of programming languages
Differentiate and explain advantages and disadvantages of the various types of
programming languages
Describe the High level languages translation processes
Describe the criteria for Programming language evaluation
High level languages are more abstract, easier to use and more portable across platforms as compared to
low-level programming languages. A programmer uses variables, arrays or Boolean expressions to
develop the logic to solve a problem. Source programs are written in statements akin to English. A high
level language code is executed by translating it into the corresponding machine language code with the
help of a compiler or interpreter. High level languages can be classified into the following categories;
Procedure-oriented languages (third generation)
Problem-oriented languages (fourth generation)
Natural languages (fifth generation).
Procedure languages.
High-level languages designed to solve general-purpose problems, example BASIC, COBOL,
FORTRAN, C, C++ and JAVA. They are designed to express the logic and procedure of a problem.
Though the syntax of the languages may be different, they use English-like commands that are easy to
follow. They are portable.
Problem-oriented languages
Problem-oriented languages also known as Fourth Generation Languages (4GL) are used to solve specific
problems and includes query languages, report generators and Application generators which have simple
English like syntax rules. The 4GLs have reduced programming efforts and overall cost of software
development. They use either visual environment or a text environment for program development similar
to that of third-generation languages. A single statement of the 4GL can perform the same task as multiple
line of a third-generation language. It allows a program to just drag and drop from the toolbar, to create
various items like buttons, text boxes, label etc. A program can quickly create a prototype of the software
applications
Natural Languages
Natural languages widely known as fifth generation languages, are designed to make a computer to
behave like an expert and solve problems. The programmer just needs to specify the problem and the
constraints for problem solving. Natural languages such as LISP and PROLOG are mainly used to
develop artificial intelligence and expert systems.
2.3.1. Compiler
A compiler is a manufacturer specifically written computer program which translates (or compiles) a
source code computer program that translates the source code written in a high level language into the
corresponding object code of the low level language. The translation process is called compilation. The
entire high level source code / program is converted into the executable machine code file prior to the
object program being loaded into main memory and executed. Translation done only ones and the object
program can be loaded into the main storage and executed. A program that translates a low-level language
into a high level language is called a Decompiler. Compiled languages includes C, C++, COBOL,
FORTRAN etc.
Compilers are classified into single-Pass compilers and Multi-pass compilers. Single-pass compilers are
generally faster than multi-pas compilers, but multi-pass compilers are required to generate high quality
code
A Compiler:
Translates the source program code into machine code
Includes linkages for closed sub-routine
Allocates areas of main storage
Produces the object program.
Produces a printed copy (listing) of the source code and object code
Produces a list of errors found during compilation.
2.3.2. Interpreter:
The interpreter is a translation program that converts each high-level language statement into the
corresponding machine code. The translation process is carried out just before the program statement is
executed. Instead of the entire program, one program statement at a time is translated and executed
immediately. When using an interpreter, the source code translated every time the program is executed
The commonly interpreted languages include BASIC and PERL. Though interpreters are easier to create
as compared to compilers, the compiled languages can be executed more efficiently and are faster.
Interpreters are appropriate in;
Handling user commands in an interactive system
Debugging programs as they run (removing program faults).
Handling software produced for or by a different computer.
The first three stages are concerned with finding and reporting errors to the programmer, while the last
two are concerned with generating efficient machine code to run on the targeted computer.
There are a number of different ways that the programmer can think about the design of the system, from
the top-down of structured programming to object oriented design issues. Some languages are geared
towards one particular style of design, whilst others incorporate many types. Each of these language
paradigms enables the programmer to consider the problem from a different viewpoint. There are a few
basic questions that can be asked to help when making these decisions:
1. How readable is the language, to humans? If parts of the program are going to be read or altered
separately from the entire program is might be worth considering how legible they are going to be. It
is also useful to consider the length of names allowed in the language, for instance an early form of
Fortran allowed for only 6 characters. This can lead to clumsy abbreviations that are difficult to read.
Statements such as GO TO, FOR, WHILE and LOOP have increased the readability of programs,
and lead to neater programs. These statements also affect the syntax or grammar.
2. When it comes to writing the program, how easy is it to write the program in this particular
language? A programming language that is easy to write in can make the process easier and faster. It
may help to reduce mistakes. FOR loops and other types of statement allow the programmer to write
much simpler code. This will save time and money, and also make the program smaller.
3. How reliable is the language? Not all languages create robust programs, and some help the
programmer to avoid making errors. A program that is not robust can cause errors, and code can
‘decay’. Any language that helps the programmer to avoid mistakes will make it easier to use.
4. How much would it cost to develop using a given language? Is the language expensive to use and to
maintain? Programs may need to be updated or redeveloped, and an expensive language may make
this prohibitive.
5. How complicated is the syntax going to be? Syntax is an important consideration. Clarity and ease of
understanding are important, as is a syntax that seems logical and sensible. Errors are very likely to
occur where one area of syntax too closely resembles another, and the program may prove difficult
to debug. Some theorists reason that if it is difficult to write a program to parse the language, then it
follows that it will be problematical for the programmer to get it right.
6. Does the language have standards? Languages that have standards for writing programs have greater
readability; for instance Java has standards for naming, commenting and capitalization.