Thursday, 14 December 2017

PROGRAMMING LANGUAGES


INTRODUCTION

Computers are machines. Unfortunately they cannot understand natural languages, such
as Hindi, English, Tamil, etc. that human beings speak and understand. Therefore, to give
instructions to computers, different languages have been developed. These languages are called
computer languages. To get a particular work done by computers, programmers write
instructions using these computer languages. Each computer language has its own vocabulary of
a natural language that we speak. Each natural language has its rules and grammar. Similarly,
each computer language too has its set of rules that are called as syntax. As computers are not
intelligent, we have to use the exact syntax rules of the computer language whenever we write
any computer program. Otherwise, the computer will not be able to understand our instructions.
Over the last few decades, several computer languages have developed. Different
computer languages are suitable for different applications. For example, COBOL (Common
business oriented Language) may be more suitable for business applications, whereas

FORTRAN may be more suitable for scientific or engineering applications. We can classify all
computer languages into three categories.



 PROGRAMMING LANGUAGES

Computer languages are classified into three categories:
1. Machine language
2. Assembly language:
3. High level languages:



 MACHINE LANGUAGE

The form in which information is denoted or represented by a combination of “1” and
“0”s is called machine language. Programs and data are ultimately represented in machine
language in memory and other hardware of the computer.
To start with computer programmers used machine language for programming. It was
tedious since each operation that the computer has to perform is denoted by a particular
combination of”1” s and”0”s.Also each computer had its own machine language code. One has
to remember all these codes to write a program.
While machine language had the drawbacks mentioned above, it was very efficient in
using computer circuits. There was no necessity for software to convert since we can directly
represent the machine language in the computer circuits without the necessity of conversion.

  •  Advantages of Machine Language:
Even though machine languages are not a human friendly language, it offers following
advantages.
a) Translation Free:Machine language is the only language that computers can directly execute without the
need for conversion. Even an application using high-level languages, has to be converted into
machine-readable form so that the computer can understand the instructions


First ProgrammerLady Lovelace Ada Augusta (officially the first programmer) suggested
binary numbers for computer storage instead of decimals. A British
mathematician, Alan Mathison Turing, was the first person to recognize that
programming in machine language is less time consuming. In 1952, John
von Neuman proposed to have new programs loaded from a magnetic tape to
read. With differences in magnetic polarities, it can mean either ON of OFF
states.

b) High Speed:Since no conversion is needed, the applications developed using machine language are
extremely fast. It is usually used for complex applications such as space control system, nuclear
reactors, and chemical processing.


  • Disadvantages of Machine Language:
There are many disadvantages in using machine language to develop programs. Some of
these are
a) Machine Dependent:Every computer type differs from the other, based on its architecture. Hence, an
application developed for a particular type of computer may not run on the other type of
computer. This any prove costly as well as difficult for the organizations.


b) Complex Language:
Machine language is very difficult to read and write. Since all the data and instructions
must be converted to binary code, it is almost impossible to remember the instructions. A
programmer must specify each operation, and the specific locations for each piece of data and
instructions to be stored. It means that a programmer practically needs to be hardware expert to
have proper control over the machine language.


c) Error Prone:Since the programmer has to remember all the opcodes and the memory locations,
machine language is bound to be error prone. It requires a super human effort to keep track of
the logic of an problem and, therefore, results in frequent programming errors.


d) Tedious:Machine language poses real problems while modifying and correcting a program.
Sometimes the programming becomes too complex to modify and the programmer has to rewrite
the entire logic again. Therefore, it is very tedious and time-consuming, and since time is a
precious commodity, programming using the machine language tends to be costly. Due to its
overwhelming limitations, machine language is rarely used nowadays.


 ASSEMBLY LANGUAGE:As computer field advanced, computer scientists felt the necessity of making computer
programming easier. They invented computer languages that are easy to remember and use.
These languages called assembly language uses mnemonic codes. for Example: For adding two
quantities X and Y, You may code as follows.


ADD X YADD is called operation code that tells the computer what operation it has to perform. X
and Y are called operation addresses. These refer to the memory addresses where the quantities
you want to add are stored. X refers to the location of first quantity and Y the second quantity.
These are called symbolic address, since they do not refer to any fixed address. Software called
assembler translates this assembly language program into machine language program which you
can load into computer memory and execute.

When the program is loaded into memory for execution the symbolic addresses are
automatically converted into actual physical addresses of operands involved in an instruction.

  •  Assembly language offers the following advantages:
a) The assembly language uses mnemonic codes, for programming. So it is easier for the
programmer to use assembly language than machine language for programming.
b) The assemblers, in addition to translating the assembler language program into machine
language, list the program statements (called source code) and also the syntax errors that the
programmer committed.


  • Assembly language has certain disadvantages too:
a) One has to spend considerable time in writing the assembly language program.b) An assembly language program has to be converted into machine language program using
assembly.
c) While it is easier to use than the machine language one still has to remember the operation
codes for various operations.


HIGH LEVEL LANGUAGES:During 1960s computers started to gain popularity and it became necessary to develop
languages that were more like natural languages such as English so that a common user could
use the computer efficiently. Since assembly language required deep knowledge of computer
architecture, it demanded programming as well as hardware skills to use computers. Due to
computer’s widespread usage, early 1960s saw the emergence of the third generations
programming languages (3GL). Languages such as COBOL, FORTRAN, BASIC, and C are
examples of 3GLs and are considered high-level languages.


High level languages are similar to English language. Programs written using these
languages can be machine independent. A single high-level statement can substitute several
instructions in machine or assembly language. Unlike assembly and machine programs, highlevel programs may be used with different types of computers with little or no modification, thus
reducing the re-programming time.
In high-level language, programs are written in a sequence of statements to solve a
problem. For example, the following BASIC code snippet will calculate the sum of two numbers
LET X = 10
LET Y = 20
LET SUM = X + Y PRINT SUM
The first two statements store 10 in variable X (memory locations name) and 20 in
variable, Y, respectively. The third statement again creates a variable named SUM, which will
store the summation of X and Y value. Finally, the output is printed, that is, the value stored in
SUM is printed on the screen.


  • Translating High-level Language to machine language:
Since computers understand only machine language, it is necessary to convert the highlevel language programs into machine language codes. This is achieved by using language
translators or language processors, generally known as compliers, interpreters or other routines
that accepts statements in one language and produces equivalent statements in another language.

a) Compiler:A compiler is a kind of translator that translates a program into another program, known
as target language. Usually, the term compiler is used for language translator of high-level
language into machine language. The complier replaces single high-level statement with a series
of machine language instruction. A compiler usually resides on a disk or the storage media.
When a program is to be complied, its complier is loaded into main memory. The compiler
stores the entire high-level program, scans it and translates the whole program into an equivalent
machine language program. During the translation process, the compiler reads the source
program and checks the syntax (grammatical) errors. If there is any error, the compiler generates
an error message, which is usually displayed on the screen. In case of errors, the compiler will
not create the object code until all the errors are rectified.


Once the program has been compiled, the resulting machine code is saved in an
executable file, which can be run on its own at any time. To be precise, once the executable is
generated, there is no need for the actual source code file. Anyway, it is worthwhile to keep the
source file(s) because if the source code is modified, it is necessary to recompile the program
again to regenerate the executable file containing amendments.



b) Interpreter:Unlike compilers, an interpreter translates a statement in a program and executes the
statement immediately, before translating the next source language statement. When an error is
encountered in the program, the execution of the program is halted and an error message is
displayed. Similar to compilers, every interpreted language such as BASIC and LISP has its
own interpreters.


  •  Advantages of high-level languages:
High-level languages (HLL) are useful in developing complex software, as they support
complex data structures. It increases the programmer’s productivity (the number of lines of code
generated per hour). Unlike assembly language, the programmer does not need to learn the
instructions set of each computer being worked with. The various advantages of using high-level
languages are discussed below:


CompilersCompiler is a program which translates source code written in a particular
programming language into computer-readable machine code that can be directly
loaded and executed. For each high-level language, a separate compiler is
required. For example, a complier for C language cannot translate a program
written in FORTRAN. Hence, to execute both language programs, the host
computer must have the compilers of both languages.

a) Readability:Since high-level languages are closer to natural languages, they are easier to learn and
understand. In addition, a programmer does not need to be aware of computer architecture; even
a common man can use it without much difficulty. This is the main reason of HLL’s popularity.


b) Machine Independent:High-level language are machine independent in the sense that a program created using HLL
can be used on different platforms with very little or no change at all.


c) Easy Debugging:High-level languages include the 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, which results in fewer errors. Moreover, the compilers and interpreters are
designed in such a way that they detect and point out the errors instantaneously.


d) Easier to Maintain:As compared to low-level languages, the programs written in HLL are easy to modify and
maintain because HLL programs are easier to understand.


e) Low Development Cost:High-level languages permit faster development of programs. Although a high-level
program may not be as efficient as an equivalent low-level program, but the savings in
programmer’s time generally outweighs the inefficiencies of the application. This is because the
cost of writing a program is nearly constant for each line of code, regardless of the language.
Thus, a high-level language, where each line of code translates to 10 machine instructions, costs
only a fraction as compared to program developed in a low-level language.


f) Easy Documentation: Since the statements written in HLL are similar to natural languages
they are easier to understand as compared to low-level languages.


  • Disadvantages of high-level languages:
The main disadvantages of this language are:a) Poor Control on Hardware:High-level languages are developed to ease the pressure on programmers so that they do not
have to know the intricacies of hardware. As a result, sometimes the applications written in
high-level languages cannot completely harness the total power available at hardware level.


b) Less Efficient:The HLL applications are less efficient as far as computation time is concerned. This is
because, unlike low-level languages, high-level languages must be created and 

No comments:

Post a Comment