Wednesday, May 11, 2011

COMPUTER PROGRAMMING: FUNDAMENTALS PART4

HIGH-LEVEL LANGUAGE

The machine and assembly languages are referred to as low-level languages because they are closest to hardware. To create programs that are hardware independent, programmers have developed a new type of programming language called the high-level language. A high-level language is user-friendly because it is similar to the English language and uses words, such as PRINT and GOTO to print and jump to a particular line, respectively. Some examples of a high-level language are Basic, COBOL, C, and Pascal.
High-level languages are also called third-generation languages.
Each instruction in a high-level language is translated into multiple machine-level instructions. High-level languages have made programming an easy task, which has increased the usage of high-level languages by programmers.
Some advantages of using a high-level language are as follows:
·         Learning a high-level language is easier than learning a machine or assembly language because their instructions are more English like.
·         A programmer can easily read, write, and maintain a program written in a high-level language. This is because high-level languages vocabularies are similar to the English language.
·         The high-level language programs being hardware independent provide the feature of portability. The high-level language program written in one type of computer can easily be used on another type of computer.
Compiler
To execute a program written in a high-level language, a computer needs translation software called a compiler.
A compiler is always language-specific which means each high-level language has its own compiler, which translates the source code of that language into the object code. For example, a compiler for COBOL compiles only the programs written in COBOL. It cannot compile programs written in any other high-level language, such as FORTRAN.

The following figure shows how a compiler works:
The preceding figure shows two programs written in two different high-level languages. The programs are compiled using the respective compilers of the languages and are converted into corresponding object code.
When a compiler program translates a source code, it checks the syntax of the statements. If the compiler finds an error in the source code, it generates a list of errors. The compiler does not generate the object code until the errors are removed.

Linker
When a program is written in any programming language, it uses predefined keywords, such as Print or Accept, whose functionalities are defined in the libraries. A library is the collection of various keywords and their functionalities, which are written by experienced programmers and stored for reuse by other programmers. These predefined keywords can be reused by giving the references of libraries in the programs.
On compilation, the compiler generates the object code. To generate the executable code from the object code the functionality of the keywords also needs to be attached. The linker performs the task of linking the functionality of the keywords with the object code.
The process of linking is shown in the following figure:

Interpreter
Some high-level languages use a different type of translator program called an interpreter. An interpreter takes each instruction of the source code, converts it to a machine language instruction, executes it and does not save the generated object code. This process is repeated each time before execution. Therefore, executing the program using an interpreter is time-consuming.
Debugging is easier using an interpreter because interpreter error messages are usually specific and point out the line on which the error occurs.
PERL, BASIC, and Visual Basic languages typically use interpreter.

Examples of High-level Languages
A large number of high-level languages have been developed since the first high-level language, FLOWMATIC, was developed in 1952. Some of the common high-level languages are Beginners All Purpose Symbolic Instruction Code (BASIC), Formula Translation (FORTRAN), Common Business Oriented Language (COBOL), Pascal, and C.


BASIC
BASIC was developed in 1964 by Professor John Kemny and Thomas Kurtz at Darmouth College in the USA.
Basic is an interpreter-based language that is easy and simple to use. BASIC was one of the earliest high-level languages to be implemented on personal computers.

FORTRAN
FORTRAN is one of the oldest high-level languages. It was developed in 1957 by John Backus and his team at International Business Machines (IBM) Corporation. FORTRAN was designed to solve scientific and engineering problems. After the first version was launched, various versions of FORTRAN have been developed, such as FORTRAN II, FORTRAN IV, and FORTRAN 77. FORTRAN IV was the first language that was standardized by American National Standards Institute (ANSI).

COBOL
COBOL was initially developed by the mathematician, Grace Hopper, in 1959. It was later modified in 1959-60 by a committee of the Conference on Data Systems Languages (CODASYL). This committee defined the language specifications for COBOL.
COBOL was standardized by ANSI in 1968. Revised versions of this standard were published in 1974 and 1985, which are known as COBOL 74 and COBOL 85, respectively. Currently, the latest version of COBOL is known as COBOL 2002.
COBOL was designed to solve business data processing problems.

Pascal
Pascal was designed in 1971 by Professor Nicklaus Wirth of the Federal Institute of Technology in Zurich, Switzerland. He named it after the famous French mathematician, Blaise Pascal.
Pascal was designed to help beginners to learn good problem solving and programming practices. Today, Pascal is recognized as a language that allows programmers to write structured and modular programs. It is suitable for scientific as well as business applications.
Pascal was standardized by ANSI in 1983. Since then, different versions of Pascal are available.

C
C was developed in 1972 by Dennis Ritchie and Brian Kernighan at AT&T’s Bell Laboratories, USA. They designed C in such a way that it incorporated the features of a high-level language along with the efficiency of a low-level language.
C was standardized by ANSI in 1989. C is a compiler-based language. Therefore, C programs can be easily transferred to other computers equipped with a C compiler. It is widely used for writing word-processing programs, compilers, and operating systems. For example, the UNIX operating system is written in C.

Selecting a Programming Language
With the availability of a wide variety of programming languages, the selection of an appropriate programming language is an important issue today. The following factors should be considered when selecting a programming language:
·         The first criterion for selecting a language is the type of application that is to be developed. For example, COBOL is for solving business data processing problems.
·         If multiple languages are suitable for an application, programmers should select a language in which they are proficient.
·         If the programmers are not familiar with any language, they should select a language that is easy to learn and use

No comments:

Post a Comment