Professional Documents
Culture Documents
c
h
a
p
t
Introduction to Software e
r 4
LEARNING
OBJECTIVES
After studying this chapter, the readers will be able to
∑ identify system programs and application programs ∑ briefly discuss compiler, interpreter, linker, and loader
∑ discuss basic concepts of high- and low-level languages functions
∑ explain the software development steps
code runs on a remote computer connected to the Internet or Machine language is considered to be the first generation
other computer network. language (1GL). As it is the native language of the computer,
CPU can directly start executing machine language
4.2 PROGRAMMING LANGUAGES instructions. But the limitations of using machine language
in writing programs include the following.
A programming language can be defined formally as an
artificial formalism in which algorithms can be expressed. It is Difficult to use and error prone It is difficult to understand
composed of a set of instructions in a language understandable and develop a program using machine language. Because it is
to the programmer and recognizable by a computer. Computer hard to understand and remember the various combinations of
languages have been continuing to grow and evolve since the 1’s and 0’s representing data and instructions. The programmer
1940’s. Assembly language was the normal choice for writing has to remember machine characteristics while preparing a
system software like operating systems, etc. But, C has program. Checking machine instructions to locate errors are
been used to develop system software since its emergence. about as tedious as writing the instructions. For anybody
The UNIX operating system and its descendants are mostly checking such a program, it would be difficult to forecast the
written in C. Application programs are designed for specific output when it is executed. Nevertheless, computer hardware
computer applications. Most programming languages are recognizes only this type of instruction code. Further,
designed to be good for one category of applications but not modifying such a program is highly problematic.
necessarily for the other. For an instance, COBOL is more Machine independent As the internal design of the
suitable for business applications whereas FORTRAN is computer is different across types, which in turn is determined
more suitable for scientific applications. by the actual design or construction of the ALU, CU, and
The development of programming languages has been size of the word of the memory unit, the machine language
governed by a number of factors such as type and performance also varies from one type of computer to another. Hence,
of available hardware, applications of computers in different it is important to note that after becoming proficient in the
fields, the development of new programming methodologies machine code of a particular computer, the programmer may
and its implementation etc. be required to learn a new machine code and would have to
write all the existing programs again in case the computer
4.2.1 Generation of Programming Languages
system is changed.
Just as hardware is classified into generations based on tech-
nology, computer languages also have a generation classifi- Second generation language (2GL)—assembly
cation based on the level of interaction with the machine. language
Assembly language is considered to be a second generation
First generation language (1GL)—machine
language (2GL). In this language, an instruction is expressed
language
using mnemonic codes instead of binary codes. Normally an
The instructions in machine language are written in the assembly language statement consists of a label, an operation
form of binary codes that can immediately be executed by code, and one or more operands. Labels are used to identify
the processor. A machine language instruction generally has and reference instructions in the program. The operation code
three parts as shown in Fig. 4.1. The first part is the operation is a symbolic notation that specifies the particular operation to
code that conveys to the computer what function has to be be performed, such as MOV, ADD, SUB, or CMP etc. The operand
performed by the instruction. All computers have operation represents the register or the location in main memory where
codes for functions such as adding, subtracting and moving. the data to be processed is located. For example, a typical
The second part “Mode” specifies the type of addressing statement in assembler to command the processor to move
used by the instruction to obtain the operand referred by the the hexadecimal number 0x80 into processor register R2
instruction. The third part of the instruction either specifies might be:
that the operand contains data on which the operation has to be
MOV R2, 080H
performed or it specifies that the operand contains a location,
the contents of which have to be subjected to the operation. The following is an example of an assembly language
program for adding two numbers A and B and storing the
n-bits
result in some memory location.
p-bits q-bits r-bits
Load register A with content of
LDA, 2000h;
• All 4GLs are designed to reduce programming effort, the guages. Both assembly language and machine language are
time it takes to develop software, and the cost of software considered as low-level languages. Low-level languages are
development. Programming productivity is increased when closer to the native language of the computer as program
4GL is used in coding. written in machine language does not require translation for
a processor to execute them. Assembly language is also con-
Fifth generation language (5GL) sidered as a low-level language since each assembly language
Natural languages represent the next step in the development instruction accomplishes only a single operation and the cod-
of programming languages belonging to Fifth Generation ing for a problem is at the individual instruction level. On
Language (5GL). Natural language is similar to query the other hand, high-level programming languages provide a
language, with one difference: it eliminates the need for the high level of abstraction from the actual machine hardware.
user or programmer to learn a specific vocabulary, grammar, High-level languages can further be characterized is by
or syntax. programming paradigm (Fig. 4.2). A programming paradigm
Actually, 5GL is a programming language based around refers to the way of problem solving that includes a set of
solving problems using constraints given to the program, methodologies, theories, practices and standards. The high-
level programming languages may also be categorized into
rather than using an algorithm written by a programmer. Fifth
three groups—procedural, non-procedural, and problem
generation languages are used mainly in artificial intelligence
oriented.
research. OPSS and Mercury are examples of fifth generation
languages. Procedural programming languages
In procedural programming, a program is conceived as
note a set of logically related instructions to be executed in
∑ A low-level computer programming language is one order. In procedural programming, each program can be
that is closer to the native language of the computer. divided into small self-contained program segment, each
Machine and assembly languages are referred to as low- of which performs a particular task and be re-used in the
level languages since the coding for a problem is at the program as and when required without repeated explicit
individual instruction level. coding corresponding to the segment. These sections of
∑ Program written in languages other than machine lan- code are known as procedures or subroutines or functions.
guage is required to be translated into machine code.
It also makes it easier for programmers to understand and
maintain program structure. There are mainly three classes of
4.2.2 Classification of Programming Languages procedural programming languages.
Programming languages can be classified in various ways. Algorithmic Using this type of programming languages,
According to the extent of translation that is required to gen- the programmer must specify the steps the computer has
erate the machine instructions from a program, programming to follow while executing a program. In these languages,
languages can be classified into low-level or high-level lan- a complex problem is solved using top-down approach
Programming language
Scripting Publishing
(VB, PERL) (LATEX)
Another class of problem oriented languages is for This process is known as parsing. Syntax is similar to the
symbolic language manipulation. For example, simplifying grammar of a language. Syntax rules specify the way in which
a complex algebraic expression or getting the indefinite valid syntactic elements are combined to form the statements
integral of a complex expression. MATHEMATICA is a of the language. Syntax rules are often described using a
popular language of this type. notation known as BNF (Backus Naur Form) grammar.
In the Internet era, a new category of languages has
emerged, the markup languages. Mark-up languages are
Source Lexical Syntactic Semantic
not programming languages. For instance, HTML, the program analysis analysis analysis
most widely used mark-up language, is used to specify the
layout of information in Web documents. However, some
programming capability has crept into some extensions to Library code
Intermediate
HTML and XML. Among these are the Java Server Pages, object code
from other code
Standard Tag Library (JSTL), and eXtensible Stylesheet compilations generation
Maintenance to it for ensuring its full time availability. The software may
In this phase, developed software is made operational. Users be required to be modified if the environment undergoes a
will have lots of questions and software problems which lead to change. Maintaining and enhancing software to cope with
the next phase of software development. Once the software has newly discovered problems or new requirements can take far
been deployed successfully, a continuous support is provided more time than the initial development of the software.
Summary
A programming language is an artificial formalism for expressing the stages. In lexical analysis phase, lexical units or tokens are produced
instructions to be executed in a specified sequence. Programming from the statements. Also symbol table is constructed to record the type
languages can be classified into low-level and high level languages. Low- and attributes information of each user-defined name in the program.
level programming languages include machine language and assembly Next, syntax analysis takes place. In this phase, tokens are grouped into
language. In fact, assembly languages were so revolutionary that they syntactic units such as expressions, and statements. that must conform to
became known as second-generation languages, the first generation being the grammatical rules of the source language to form a data structure called
the machine languages themselves. Assembly languages are symbolic parse tree. In semantic analysis, the parse trees are analysed further to
programming languages that use symbolic notation to represent machine- make sure that the operators and operands do not violate source language
language instructions. type specification. Then, to produce a more efficient target program, the
Most third generation languages are procedural languages. Compilers intermediate code is generated which is then optimized. In the last phase,
convert the program instructions from human understandable form to the object code in target language is produced. Linking resolves symbolic
machine understandable form. Interpreters also convert the source program references between object programs. A loader is a system program that
to machine language instruction but execute each line as it is entered. The accepts object programs and prepares them for execution and initiates the
translation of the source program takes place for every run and is slower execution. Programming is an individual’s effort and requires no formal
than the compiled code. The system software controls the activities of a systematic approach. Software development is more than programming. It
computer, application programs, flow of data in and out of memory and disk involves a series of steps–feasibility study, requirement analysis, design,
storage. Compilation of a source code into target code follows successive coding, testing, deployment and maintenance.
Key Terms
Loader It is a system program that accepts object programs and Syntax It refers to the rules governing the computer operating system,
prepares these programs for execution by the computer and initialize the the language, and the application.
execution. Assembler It is a program that translates an assembly language
Linker It takes one or more object files or libraries as input and combines program into machine code.
them to produce a single (usually executable) file. Bug It is a programming error.
Compiler It is a system software that translates the entire source Debugging It is the process of eliminating errors from a program.
program into machine language.
Semantic It is the meaning of those expressions, statements, and
Interpreter An interpreter is a system software that translates the source program units.
program into machine language line by line.
The symbol table serves as a database for the compilation process. It Not much helpful in debugging. Very helpful in debugging.
records the type and attributes information of each user-defined name in Compilation process is faster. Interpretation process is slower.
the program. This table is used in sytax analysis, semantic analysis as well
Gives a list of all errors in the program. Stops at the first error.
as in code generation phases of compilation.
exercises
1. What do you mean by a program? 9. Briefly explain linker and loader. Is there any difference between
2. Distinguish between system software and application software. them?
3. State the advantages and disadvantages of machine language and 10. Explain linking loader and linkage editor.
assembly language. 11. Classify the programming languages.
4. Compare and contrast assembly language and high-level language. 12. What is a functional language?
5. Differentiate between 3GL and 4GL. 13. What is object-oriented language? Name five object-oriented
6. What is a translator? programming languages.
7. What are the differences between a compiler and an interpreter? 14. What is the difference between linking loader and linkage editor?
8. Briefly explain the compilation and execution of a program written in a 15. What is relocation?
high-level language.