0% found this document useful (0 votes)
27 views21 pages

Advantages of Assembly Language

This chapter introduces computer programming and languages. It discusses the program development life cycle, including problem analysis, algorithm development, coding, testing and debugging. It also explains that computers require instructions in programming languages rather than natural languages. Programming languages have evolved from machine language using binary, to assembly language using symbols, to modern high-level languages that more closely resemble human languages.

Uploaded by

Poorna. M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views21 pages

Advantages of Assembly Language

This chapter introduces computer programming and languages. It discusses the program development life cycle, including problem analysis, algorithm development, coding, testing and debugging. It also explains that computers require instructions in programming languages rather than natural languages. Programming languages have evolved from machine language using binary, to assembly language using symbols, to modern high-level languages that more closely resemble human languages.

Uploaded by

Poorna. M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter 10

Computer Programming and Languages

This chapter introduces the reader with the fundamentals of computer programming and
languages. A computer program refers to the set of instructions needed for performing a
particular task. Computer or programming language refers to the vocabulary and set of
grammatical rules that are required to instruct a computer to perform a specific task. The
chapter begins with the life cycle of program development and various programming tools which
are essential for making a computer program. The discussion continues with various
programming control structures and programming paradigms. Next, the chapter explains the
evolution of various programming languages and generations of programming languages. The
reader is also familiarised with the working of languge translators, namely, assembler, compiler,
and interpreter.

10.1 INTRODUCTION

The computer has emerged as the most useful machine in recent times. It can perform a variety
of tasks like receiving data, processing it and producing useful results. However, being a
machine, the computer cannot perform on its own. A computer needs to be instructed to perform
even a simple task like adding two numbers. Computers work on a set of instructions
called computer program, which clearly specify the ways to carry out a task. An analogy of this
may be thought of as the instructions given by the manager or team leader to its team. The team
members follow those instructions and accordingly perform their duties. Similarly, a computer
also takes instructions in the form of computer programs to carry out the requested task.

Now the question that arises is how human beings instruct computers. We, as human beings, use
natural languages such as English, Spanish or French to communicate. Similarly, a user
communicates with the computer in a language understood by it. Note that human beings cannot
interact directly with the computer using natural languages because thus far we have not
developed such computers that can comprehend natural languages. Rather, the instructions,
provided in the form of computer programs, are developed using computer or programming
languages. This chapter provides some of the most prominent concepts related to computer
programming and languages.

10.1.1 Developing a Program

As discussed earlier, a program consists of a series of instructions that a computer processes to


perform the required operation. In addition, it also includes some fixed data required to perform
the instructions and the process of defining those instructions and data. Thus, in order to design a
program, a programmer must determine three basic rudiments:

 The instructions to be performed.


 The order in which those instructions are to be performed.
 The data required to perform those instructions.

To perform a task using a program, a programmer has to consider various inputs of the program
along with the process, which is required to convert the input into desired output. Suppose we
want to calculate the sum of two numbers, A and B, and store the sum in C; here A and B are the
inputs, addition is the process, and C is the output of the program (see Figure 10.1).

Figure 10.1 Program Performing a Task

10.1.2 Program Development Cycle

Before starting the process of writing a program (coding), the programmer has to determine the
problem that needs to be solved. There are different approaches to problem solving. One
common approach is to use the program development cycle, with the number of steps that may
vary according to the person who has formalized the development. Often the process runs in a
loop, for example, as the current process is completed, new demands appear and the
development process commences again. Illustrated in Figure 10.2 is the development cycle of a
program, which includes the following phases.

Figure 10.2 Program Development Cycle

 Problem Analysis: The problem is analysed precisely and completely. Based on


understanding, the developer knows about the scope within which the problem needs
to be developed.
 Task Analysis: After analysing the problem, the developer needs to develop various
solutions to solve the given problem. From these solutions, the optimum solution is
chosen, which can solve the problem comfortably and economically.
 Algorithm Development: After selecting the appropriate solution, an algorithm is
developed to depict the basic logic of the selected solution. An algorithm depicts the
solution in logical steps (sequence of instructions). Further, an algorithm is represented
by flowcharts, decision tables and pseudocodes. These tools make the program logic
clear and they eventually help in coding.
 Algorithm Testing: Before converting the algorithms into actual code, it should be
checked for accuracy. The main purpose of checking the algorithm is to identify major
logical errors at an early stage because logical errors are often difficult to detect and
correct at later stages. The testing also ensures that the algorithm is a “true” one and it
should work for both normal as well as unusual data.
 Coding: After meeting all the design considerations, the actual coding of the program
takes place in the chosen programming language. Depending upon the application
domain and available resources, a program can be written by using computer
languages of different levels such as machine, assembly or high-level languages
(HLL).
 Testing and Debugging: It is common for the initial program code to contain errors.
A program compiler and programmer-designed test data machine tests the code for
syntax errors. The results obtained are compared with results calculated manually from
these test data. Depending upon the complexity of the program, several rounds of
testing may be required.
 Documentation: Once the program is free from all the errors, it is the duty of the
program developers to ensure that the program is supported by suitable documentation.
These documents should be supplied to the program users. Documenting a program
enables the user to operate the program correctly. It also enables other persons to
understand the program clearly so that it may, if necessary, be modified, or corrected
by someone other than the original programmer.
 Implementation: After documentation, the program is installed on the end user's
machine and the user is also provided with all the essential documents in order to
understand how the program works. The implementation can be viewed as the final
testing because only after using the program the user can point out the drawbacks (if
any) and report them to the developers. Based on the feedback from users, the
programmers can modify or enhance the program.
 Maintenance and Enhancement: After the program is implemented, it should be
properly maintained by taking care of the changing requirements of its users and
the system. The program should be regularly enhanced by adding additional
capabilities. This phase is also concerned with detecting and fixing the errors, which
were missed in the testing phase. Since this step generates user feedback, the
programming cycle continues as the program is modified or reconstructed to meet the
changing needs.

10.9 PROGRAMMING LANGUAGES

Previously, we discussed that a computer needs to be instructed using computer programs to


perform all its tasks. To write computer programs, a computer or programming language is
required, as computers do not understand natural languages (like English). A programming
language consists of a set of characters, symbols and usage rules that allow the user to
communicate with computers just as natural languages are used for communication among
human beings.

You might be wondering why natural languages are not used to instruct the computers. There are
mainly two reasons behind it. Firstly, the natural languages (English, Spanish) are ambiguous,
vaguely structured, and have very large (and ever changing) vocabularies. In contrast, computer
languages have relatively few, exactly defined rules for composition of programs, and strictly
controlled vocabularies in which unknown words must be defined before they can be used.
Secondly, in case of natural languages, we can understand even while using poor grammar and
vocabulary. However, in the case of programming languages, the rules are very rigid and the
programmer has to follow all the specified rules to create an accurate program and to obtain the
desired results.

10.9.1 Types of Programming Languages

Computers understand only one language and that is binary language or the language of 0s and
1s. In the initial years of computer programming, all the instructions were given in binary form
only. Although these programs were easily understood by the computer, it proved too difficult
for a normal human being to remember all the instructions in the form of 0s and 1s. Therefore,
the computer remained a mystery to a common person until other languages such as assembly
and HLL were developed which were easier to learn and understand. These languages use
commands that have some degree of similarity with English (such as “if else”, “exit”).
Programming languages can be divided into three major categories:

 Machine Language: It is the native language of computers. It uses only 0s and 1s to


represent data and instructions.
 Assembly Language: It correspondences symbolic instructions and executable
machine codes and was created to use letters instead of 0s and 1s.
 High-level Language: These languages are written using a set of words and symbols
following some rules similar to a natural language such as English. The programs
written in HLL are known as source programs and these programs are converted into
machine-readable form by using compilers or interpreters.

Note: Together, machine and assembly language are also known as low-level languages.

10.10 GENERATIONS OF PROGRAMMING LANGUAGES

Since early 1950s, programming languages have evolved tremendously. This evolution has
resulted in the development of hundreds of different languages. With each passing year, the
languages become user-friendly and more powerful. We can illustrate the development of all the
languages in five generations.

First generation languages are machine languages, in which instructions are particular sequences
of 0s and 1s that digital computers can understand. Second generation languages, assembly
languages, allow programmers to use meaningful abbreviations for machine-specific instructions
in place of the incomprehensible 0s and 1s form. Each instruction in an assembly language
translates directly to a machine language instruction using a tool called
an assembler. Programming became somewhat easier, but many users still wanted floating-point
numbers and array indexing. Since these capabilities were not supported in hardware, HLL had
to be developed to support them. The next few sections discuss the five generations of languages
and how they revolutionized the computer industry.

10.10.1 First Generation: Machine Language

The first language was binary, also known as machine language, which was used in the earliest
computers and machines. We know that computers are digital devices, which have only two
states, ON and OFF (1 and 0). Therefore, every instruction and data should be written using 0s
and 1s. Machine language is also known as the computer's “native” language as this system of
codes is directly understood by the computer.

THINGS TO REMEMBER

First Programmers

Lady 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 or OFF states.

Instruction in machine language consists of two parts (see Figure 10.12). The first part is an
operation which tells the computer what functions are to be performed. The second part of the
instruction is the operand, which tells the computer where to find or store the data on which the
desired operation is to be performed.

Figure 10.12 Machine Language Instruction Format

A binary program is a long list of instructions that are executed by the CPU. Normally,
instructions are executed one after the other, but program flow may be influenced by special
jump instructions that transfer execution to an instruction other than the following one. Each
computer has its own set of instructions based on its architecture. Hence, machine language may
differ from computer to computer.
Advantages of Machine Language: Even though machine language is not a human-friendly
language, it offers the following advantages.

 Translation Free: Machine language is the only language that computers can directly
execute without the need for conversion. Even an application using HLL has to be
converted into machine-readable form so that the computer can understand the
instructions.
 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 as follows.

 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 another type of computer. This may prove costly as well as difficult for the
organizations.
 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 location for each piece of data and instruction to be stored. It means that a
programmer practically needs to be a hardware expert to have proper control over the
machine language.
 Error Prone: Since the programmer has to remember all the opcodes and memory
locations, machine language is bound to be error prone. It requires a superhuman effort
to keep track of the logic of the problem, and therefore results in frequent
programming errors.
 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 machine
language tends to be costly.

Due to its overwhelming limitations, machine language is rarely used nowadays.

10.10.2 Second Generation: Assembly Language

The complexities of machine language led to the search of another language: the assembly
language, developed in the early 1950s and its main developer was IBM. However, Jack Powell,
Bob Nevelen, Clement and Michael Bradly also helped in the development of the assembly
language. It was a stepping-stone for all subsequent language development. Assembly language
allows the programmer to interact directly with the hardware. This language assigns a mnemonic
code to each machine language instruction to make it easier to remember or write. It allows
better human-readable method of writing programs as compared to writing in binary bit patterns.
However, unlike other programming languages, assembly language is not a single language, but
a group of languages. Each processor family (and sometimes individual processors within a
processor family) has its own assembly language.

An assembly language provides a mnemonic instruction, usually three letters long,


corresponding to each machine instruction. The letters are usually abbreviated indicating what
the instruction does. For example, ADD is used to perform an addition operation, SUB for
subtraction, and so on. Assembly languages make it easier for humans to remember how to write
instructions to the computer, but an assembly language is still a representation of the computer's
native instruction set. Since each type of computer uses a different native instruction set,
assembly languages cannot be standardized from one machine to another, and instructions from
one computer cannot be expected to work on another.

The basic unit of an assembly language program is a line of code. It allows the use of symbols
and set of rules that can be used and combined to form a line of code. Each line of an assembly
language program consists of four columns called fields. The general format of an assembly
instruction is as follows.

[Label] <Opcode><Operands> [; Comment]

[…] brackets indicate that enclosed specification may or may not appear in a statement. If a label
is specified, it is associated as a symbolic name with the machine words generated for the
assembly statement. If multiple operands are used, each of them is separated by a comma. The
text after semicolon (;) is just comments. Comments are not a part of actual program, but are
used just for reference purposes, that is, to specify what actually the statement will do. Although
comments are optional, they are included to facilitate proper documentation. For example,

Note: The first character of an assembly language variable should be an alphabet. The rest
of the characters may be alphabets or digits. However, the total number of characters
should not exceed 8.

Assembler: This language is nothing more than a symbolic representation of machine code,
which allows symbolic designation of memory locations. However, no matter how close
assembly language is to machine code, the computer still cannot understand it. The assembly
language program must be translated into machine code by a separate program called
an assembler. The assembler program recognizes the character strings that make up the symbolic
names of the various machine operations, and substitutes the required machine code for each
instruction. At the same time, it also calculates the required address in memory for each
symbolic name of a memory location, and substitutes those addresses for the names resulting in a
machine language program that can run on its own at any time. In short, an assembler converts
the assembly codes into binary codes and then it assembles the machine understandable code into
the main memory of the computer, making it ready for execution (see Figure 10.13).

Figure 10.13 Working of an Assembler

The original assembly language program is also known as the source code, while the final
machine language program is designated the object code. If an assembly language program needs
to be changed or corrected, it is necessary to make the changes to the source code and then re-
assemble it to create a new object program. The functions of an assembler are given below.

 It translates mnemonic operation codes to machine code and corresponding register


addresses to system addresses.
 It checks the syntax of the assembly program and generates diagnostic messages on
syntax errors.
 It assembles all the instructions in the main memory for execution.
 In case of large assembly programs, it also provides linking facility among the
subroutines.
 It facilitates the generation of output on the required output medium.

Advantages of Assembly Language: The advantages of using assembly language to develop a


program are as follows.

 Easy to Understand and Use: Assembly language uses mnemonics instead of using
numerical opcodes and memory locations used in machine language. Hence, the
programs written in assembly language are much more easier to understand and use as
compared to its machine language counterpart. Being a more user-friendly language as
compared to machine language, assembly programs are easier to Modify.
 Less Error Prone: Since mnemonic codes and symbolic addresses are used, the
programmer does not have to keep track of the storage locations of the information and
instructions. Hence, there are fewer errors while writing an assembly language
program. Even in case of errors, assembly programs provide better facility to locate
and correct them as compared to machine language programs. Moreover, assemblers
also provide various mechanisms to locate the errors. For example, in case of adding
two variables such as ADD A, B if the variables (A and B) are not defined in the
program, the assembler will give an error indicating the same so that the programmer
can easily correct the mistake.
 Efficiency: Assembly programs can run much faster and use less memory and other
resources than a similar program written in a high-level language. Speed increment of
2–20 times faster is common, and occasionally, an increase of hundreds of times faster
is also possible.
 More Control on Hardware: Assembly language also gives direct access to key
machine features essential for implementing certain kinds of low-level routines such as
an operating system kernel or micro-kernel, device drivers and machine control.

Disadvantages of Assembly Language: The disadvantages in using assembly language to


develop a program are as follows.

 Machine Dependent: Different computer architectures have their own machine and
assembly languages, which means that programs written in these languages are not
portable to other, incompatible systems. This makes it a low-level language. If an
assembly program is to be shifted to a different type of computer, it has to be modified
to suit the new environment.
 Harder to Learn: The source code for an assembly language is cryptic and in a very
low machine-specific form. Being a machine-dependent language, every type of
computer architecture requires a different assembly language, making it hard for a
programmer to remember and understand every dialect of assembly. More skilled and
highly trained programmers, who know all about the logical structure of the computer,
can only create applications using assembly language.
 Slow Development Time: Even with highly skilled programmers, assembly generated
applications are slower to develop as compared to high-level-language-based
applications. In the case of assembly language, the development time can be 10–100
times as compared to a high-level-language-generated application.
 Less Efficient: A program written in assembly language is less efficient than machine
language because every assembly instruction has to be converted into machine
language. Therefore, the execution of assembly language program takes more time
than a machine language program. Moreover, before executing an assembly program,
the assembler has to be loaded in the computer's memory for translation and occupies a
sizeable memory.
 No Standardization: Assembly languages cannot be standardized because each type
of computer has a different instruction set, and therefore, a different assembly
language.
 No Support for Modern Software Engineering Technology: Assembly languages
provide no inherent support for software engineering technology. They work with just
machine-level specifics, not with abstractions. Assembly language does not provide
inherent support for safety-critical systems. It provides very little opportunity for reuse
and there is no OOP support. There is also no specific support for distributed systems.
The tools available for working with assembly languages are typically very low-level
tools.

10.10.3 Third Generation: High-level Language

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 the
computer's widespread usage, the early 1960s saw the emergence of the third generation
programming languages (3GL). Languages such as COBOL, FORTRAN, BASIC and C are
examples of 3GLs and are considered HLL.

HLL are similar to the 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, high-level programs may be used
with different types of computers with little or no modification, thus reducing the re-
programming time.

In a 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 location 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.

THINGS TO REMEMBER

Compilers

Compiler 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 compiler 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.

Translating High-level Language into Machine Language: Since computers understand


only machine language, it is necessary to convert the high-level language programs into machine
language codes. This is achieved by using language translators or language processors, generally
known as compilers, interpreters or other routines that accept statements in one language and
produces equivalent statements in another language (see Figure 10.14).

Figure 10.14 Program Translation Hierarchy

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 compiler replaces a single high-level statement with a
series of machine language instructions. A compiler usually resides on a disk or other storage
media. When a program is to be compiled, its compiler 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.
Interpreter Unlike compilers, an interpreter translates a statement in a program and executes
the statement immediately, before translating the next source language statement (see Figure
10.15). 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.

Figure 10.15 (a) Working of a Compiler (b) Working of an Interpreter

Linker: An application usually consists of hundreds or thousands of lines of codes. The codes
are divided into logical groups and stored in different modules so that the debugging and
maintenance of the codes becomes easier. Hence, for an application, it is always advisable to
adhere to structural (modular) programming practices. When a program is broken into several
modules, each module can be modified and compiled independently. In such a case, these
modules have to be linked together to create a complete application. This job is done by a tool
known as linker. A linker is a program that links several object modules and libraries to form a
single, coherent program (executable). Object modules are the machine code output from an
assembler or compiler and contain executable machine code and data, together with information
that allows the linker to combine the modules together to form a program.

Generally, all HLL use some in-built functions like calculating square roots, finding logarithm
values and so on. These functions are usually provided by the language itself, the programmer
does not need to code them separately. During the program execution process, when a program
invokes any in-built function, the linker transfers the control to that program where the function
is defined, by making the addresses of these functions known to the calling program.

Loader: Loaders are a part of the operating system that brings an executable file residing on
disk into memory and starts its execution. It is responsible for loading, linking and relocation. In
computing, a loader is a program that performs the functions of a linker and then immediately
schedules the executable code for execution, without necessarily creating an executable file as an
output. A loader performs four basic tasks as follows.

1. Allocation: It allocates memory space for the programs.


2. Linking: It combines two or more separate object programs and supplies the
information needed to allow references between them.
3. Relocation: It prepares a program to execute properly from its storage area.
4. Loading: It places data and machine instructions into the memory.

There are two types of loaders.

 Absolute Loader: It loads the file into memory at the location specified by the
beginning portion (header) of the file and then passes control to the program. If the
memory space specified by the header is currently in use, execution cannot proceed,
and the user must wait until the requested memory becomes free. Moreover, this type
of loader performs only the loading function. It does not perform linking and program
relocation.
 Relocating Loader: This loader loads the program in memory, altering the various
addresses as required to ensure correct referencing. The decision as to where in
memory the program is placed, is made by the operating system, not the file's header.
It is a more efficient loader, but there is a slight overhead in terms of a small delay
whilst all the relative offsets are calculated. The relocating loader can only relocate
code that has been produced by a linker capable of producing relative code.

Advantages of 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 instruction set of each computer being worked with. The various advantages of using
HLL are discussed below.

 Readability: Since HLL 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 lay person can use it without much difficulty. This is the main
reason of HLL's popularity.
 Machine Independent: HLL 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.
 Easy Debugging: HLL 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.
 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.
 Low Development Cost: HLL 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 ineffciencies 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, an HLL, where each line of code translates to 10
machine instructions, costs only a fraction as compared to the program developed in a
low-level language.
 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 as


follows.

 Poor Control on Hardware: HLL 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 HLL cannot completely harness the total power available at the
hardware level.
 Less Efficient: The HLL applications are less efficient as far as computation time is
concerned. This is because, unlike low-level languages, HLL must be created and sent
through another processing program known as a compiler. This process of translation
increases the execution time of an application. Programs written in HLL take more
time to execute, and require more memory space. Hence, critical applications are
generally written in low-level languages.

10.10.4 Fourth Generation

Fourth generation languages (4GLs) have simple, English-like syntax rules, commonly used to
access databases. The 3GLs are considered as procedural languages because the programmer
must list each step and must use logical control structures to indicate the order in which
instructions are to be executed. 4GLs, on the other hand, are non-procedural languages. The non-
procedural method is simply to state the needed output instead of specifying each step one after
another to perform a task. In other words, the computer is instructed what it must do rather
than how a computer must perform a task.

The non-procedural method is easier to write, but has less control over how each task is actually
performed. When using non-procedural languages, the methods used and the order in which each
task is carried out is left to the language itself; the user does not have any control over it. In
addition, 4GLs sacrifice computer efficiency in order to make programs easier to write. Hence,
they require more computer power and processing time. However, with the increase in power
and speed of hardware and with diminishing costs, the uses of 4GLs have spread.

4GLs have a minimum number of syntax rules. Hence, common people can also use such
languages to write application programs. This saves time and allows professional programmers
for more complex tasks. The 4GLs are divided into three categories:

 Query Languages: They allow the user to retrieve information from databases by
following simple syntax rules. For example, the database may be requested to
locate details of all employees drawing a salary of more than $10,000. Structured
Query Language (SQL) and IBM's Query-By-Example (QBE) are examples of query
languages.
 Report Generators: They produce customized reports using data stored in a database.
The user specifies the data to be in the report, the report's format, and whether any
subtotals and totals are needed. Often report specifications are selected from pull-down
menus, making report generators very easy to use. Examples of report generators are
Easytrieve Plus by Pansophic and R&R Relational Report Writer by Concentric Data
Systems.
 Application Generators: With application generators, the user writes programs to
allow data to be entered into the database. The program prompts the user to enter the
needed data. It also checks the data for validity. Cincom System's MANTIS and ADS
by Cullinet are examples of application generators.

Advantages of 4GLs: The main advantage of 4GLs is that a user can create an application in a
much shorter time for development and debugging than with other programming languages. The
programmer is only interested in what has to be done and that too at a very high level. Being
non-procedural in nature, it does not require the programmers to provide the logic to perform a
task. As a result, lot of programming effort is saved. Use of procedural templates and data
dictionaries allow automatic type checking (for the programmer and for user input) and this
results in fewer errors. Using application generators, the routine tasks are automated.

Disadvantages of 4GLs: Since programs written in a 4GL are quite lengthy, they need more
disk space and a large memory capacity as compared to 3GLs. These languages are inflexible
also because the programmers control over language and resources is limited as compared to
other languages. These languages cannot directly utilize the computer power available at the
hardware level as compared to other levels of languages.
10.10.5 Fifth Generation: Very High-level Languages

Fifth generation languages are just the conceptual view of what might be the future of
programming languages. These languages will be able to process natural languages. The
computers would be able to accept, interpret and execute instructions in the native or natural
language of the end users. The users will be free from learning any programming language to
communicate with the computers. The programmers may simply type the instruction or simply
tell the computer by way of microphones what it needs to do. Since these languages are still in
their infancy, only a few are currently commercially available. They are closely linked to
artificial intelligence and expert systems.

10.11 FEATURES OF A GOOD PROGRAMMING LANGUAGE

The features of one programming language may differ from the other. One can be easy and
simple while others can be difficult and complex. We judge the success and strength of a
programming language with respect to standard features. To begin the language selection
process, it is important to establish some criteria for what makes a language good.

Ease of Use: The language should be easy in writing codes for the programs and executing
them. The ease and clarity of a language depends upon its syntax. It should be capable enough to
provide clear, simple and unified set of concepts. The vocabulary of the language should
resemble English (or some other natural language). Symbols, abbreviations and jargon should be
avoided unless they are already known to most people. Any concept that cannot easily be
explained to amateurs should not be included in the language.

Simplicity helps in the readability of the language. A simple language is easier to grasp and code.
Developing and implementing a compiler or interpreter is also easier for simple languages as
compared to complex ones.

Portability: The language should support the construction of code in a way that it could be
distributed across multiple platforms (operating systems). Computer languages should be
independent of any particular hardware or operating system, that is, programs written on one
platform should be able to be tested or transferred to any other computer or platform and there it
should perform accurately.

Naturalness for the Application: The language should have a syntax which allows the
program structure to show the underlying logical structure of algorithm. A programming
language should provide a conceptual framework for thinking through algorithms and means of
expressing those algorithms through flowcharts. The advantage of displaying a program in
algorithms and flowcharts is that even a novice can understand them easily without learning any
programming language.

Reliability: The language should support construction of components that can be expected to
perform their intended functions in a satisfactory manner throughout its lifetime. Reliability is
concerned with making a system failure free, and thus is concerned with all possible errors. The
language should provide support for preventing errors. For example, some errors can be
prevented by strict syntax checking. Apart from prevention, the language should also be able to
detect and report errors in the program. For example, errors such as arithmetic overflow and
assertions should be detected properly and reported to the programmers immediately so that the
error can be rectified. The language should provide reliability by supporting explicit mechanisms
for dealing with problems that are detected when the system is in operation (exception handling).

Safety: It is concerned with the extent to which the language supports the construction of
safety-critical systems, yielding systems that are fault-tolerant, fail-safe, or robust in the face of
systemic failures. The system must always do what is expected and be able to recover from any
situation that might lead to a mishap or actual system hazard. Thus, safety tries to ensure that any
failure that results in minor consequences, and even potentially dangerous failures are handled in
a fail-safe fashion. Language can facilitate this through such features as built-in consistency
checking and exceptional handling.

Performance: By performance, we mean that the language should not only be capable of
interacting with the end users, but also with the hardware. The language should also support
software engineering mechanism, discouraging or prohibiting poor practices and supporting
maintenance activities. Nowadays, the hardware has become very sophisticated and quiet fast.
Hence, the application developed using a good language should tap the maximum resources of
the available hardware power in terms of speed and memory efficiency.

Cost: Cost component is a primary concern before deploying a language at a commercial level.
It includes several costs such as the following.

 Program execution and translation cost.


 Program creation, testing and usage cost.
 Program maintenance cost.

Promote Structured Programming: We know that structured programming is the best way to
create an application. Hence, a good language should be capable of supporting structured
programming. Since, by nature, structured programming facilitates ease in understanding the
code, a program is easier to create, debug and maintain. A structured program also helps
programmers to visualize the problem in a logical way, thereby reducing the probability of errors
in the code.

Compact Code: A language should promote compact coding, that is, the intended operations
should be coded in a minimum number of lines. Even if the language is powerful, and is not able
to perform the tasks in a small amount of code, then it is of no use. The main reason behind it is
that a large code requires more testing and developing time, thereby increasing the cost of
developing an application.

Maintainability: Creating an application is not the end of the system development. It should
be maintained regularly so that it can be easily modified to satisfy new requirements or to correct
deficiencies. Maintainability is actually facilitated by most of the languages, which makes it
easier to understand and then change the software. Maintainability is closely linked with the
structure of the code. If the original code is written in an organized way (structural
programming) then it would be easy to Modify or add new changes.

Reusability: The language should facilitate the adaptation of code for use in other
applications. Code is reusable when it is independent of other codes. It is very common, for
example, to reuse common data structures such as stacks, queues and trees. When these have
been defined with common operations on the structures, these abstract data types are easy to
reuse.

Provides Interface to Other Language: From the perspective of the language, interface to
other language refers to the extent to which the selected language supports the interfacing feature
to other languages. This type of support can have a significant impact on the reliability of the
data, which is exchanged between two applications, developed with different languages. In case
of data exchange between units of different languages, without specific language support, no
checking may be done on the data or even on their existence. Hence, the potential for
unreliability becomes high.

Concurrency Support: Concurrency support refers to the extent to which inherent language
supports the construction of code with multiple threads of control (also known as parallel
processing). For some applications, multiple threads of control are very useful or even necessary.
This is particularly true for real-time systems and those running on architecture with multiple
processors. Although, concurrency is rarely supported by a language directly, language support
can make concurrent processing more straightforward and understandable, and it can also
provide the programmer with more control over its implementation.

Standardization: Standardization means the extent to which the language definition has been
formally standardized (by recognized bodies such as ANSI and ISO) and the extent to which it
can be reasonably expected that this standard will be followed in a language translator. Non-
standard languages may soon become obsolete, rendering it inferior and difficult to use,
producing inferior code, which is difficult to maintain. Lack of appropriate support compromises
developer productivity and system quality. It also compromises the ease of development, as well
as performance and reliability of the code. If the reliability of the code is compromised, not only
will the system perform below expectations, but it will also become much more costly during its
lifetime.

LET US SUMMARIZE

1. A computer needs to be instructed to perform all its tasks. These instructions are
provided in the form of a computer program. Programming involves many stages such
as problem definition, task analysis, developing algorithm, testing algorithm, coding,
program testing, documentation, implementation, and maintenance and enhancement.
2. An algorithm is defined as a finite sequence of explicit instructions that when provided
with a set of input values produces an output and then terminates. Algorithms can be
represented as flowchart, pseudocode or decision table.
3. A flowchart is a pictorial representation of an algorithm in which the steps are drawn
in the form of different shapes of boxes and the logical flow is indicated by
interconnecting arrows. The boxes represent operations and the arrows represent the
sequence in which the operations are implemented.
4. A decision table is a way of representing the problem statement in a tabular form. It
contains all the possible conditions for a specific problem and the corresponding
results using condition rules that connect conditions with results.
5. Pseudocode is a generic way of describing an algorithm without the use of any specific
programming language-related notations. It is an outline of a program, written in a
form, which can easily be converted into real programming statements. Pseudocode
uses plain English statements rather than symbols to represent the processes in a
computer program.
6. Program statements that affect the order in which statements are executed, or that
affect whether statements are executed, are called control structures. They affect the
flow of simulation code since a control structure evaluates statements and then
executes code according to the result.
7. There are three control structures, which are used in the case of designing a solution
for a problem. These are sequential, selection and repetition. A sequence structure is a
linear progression where one task is performed sequentially after another.
A selection structure allows the program to make a choice between two alternate paths
depending upon whether a conditional statement is true or false.
A repetition or loop logic causes an interruption in the normal sequence of processing
and directs the system to move back to a previous statement in the program, repeating
the same sequence again.
8. Programming paradigm refers to how a program is written in order to solve a problem.
It provides (and determines) the view that the programmer has of the execution of the
program. Broadly, programming can be classified in the following three
categories: unstructured programming, structured programming and object-oriented
programming.
9. Unstructured programming refers to writing small and simple programs consisting of
only one main program. All the actions such as providing input, processing and
displaying output are done within one program only.
10. Using structured programming, a program is broken down into small independent
tasks, each having a single point of entry and exit. Each task has its own functionality
and performs a specific part of the actual processing.
11. In object-oriented programming, the programs are organized as cooperative collections
of objects, each of which represents an instance of some class, and whose classes are
members of a hierarchy of classes united by way of an inheritance relationship.
12. Programming language is a language that a user employs to interact with the
computer. It can be divided into three major categories: machine, assembly and high-
level language.
13. First generation language is the machine language in which instructions are in the form
of 0s and 1s. Second generation language is the assembly language in which
mnemonic code is assigned to each machine language instruction to make it easier to
remember and write. 3GLs are machine independent, use HLL to write programs, and
thus need language translators to translate the high-level code into machine code.
4GLs, also called as non-procedural languages, use minimum syntax rules and are
categorized into query languages, report generators and application generators. Fifth
generation language is in the development stage. The computer will be able to accept,
interpret and execute the instruction in the natural language of the user.
14. Linker is a program that links together several object modules and libraries to form a
single, coherent executable program. Loader is a program that brings an executable file
residing on a disk into a memory. It is also responsible for performing basic tasks such
as linking, loading and relocation.
15. A good programming language should be easier to use and be portable. It should incur
the minimum cost and provide concurrent support.

Common questions

Powered by AI

Assembly language offers advantages over machine language such as ease of understanding, fewer errors, higher efficiency, and greater control over hardware. However, it is machine-dependent, harder to learn, and less efficient in terms of development time and standardization. These characteristics limit its use in modern programming to specialized areas like low-level hardware control and performance-critical tasks .

Safety in programming languages is integrated through features like exception handling and built-in consistency checking, which help build systems that are fail-safe and robust. This is crucial for creating fault-tolerant systems, allowing them to recover from failures safely, thereby enhancing overall system reliability .

The key phases involved in program development and maintenance include testing, documentation, implementation, and maintenance and enhancement. Testing ensures all errors are found and fixed. Documentation supports user operation and future modifications. Implementation involves installing the program and obtaining user feedback to improve the software. Maintenance and enhancement involve updating the program according to user needs and improving features. This cycle ensures the program remains functional and up-to-date with user requirements .

Structured programming divides programs into sections with clear, logical flow, facilitating easier understanding, debugging, and maintenance. This structure helps reduce errors and enhances readability, significantly improving software quality by making programs more predictable and easier to handle .

Fifth-generation languages focus on using natural language processing and are closely linked to AI and expert systems. Unlike earlier generations, which require understanding specific syntax and programming logic, fifth-generation aims to allow users to communicate in natural language. This promises greater accessibility, reducing the need to learn complex programming languages, but they are still largely conceptual and not fully realized commercially .

The transition from machine language to assembly language was driven by the complexity and error-prone nature of writing in binary code. Assembly language introduced mnemonic codes, making instructions easier to remember and write. It allowed more human-readable code while maintaining closeness to machine operations, thus improving programming efficiency and reducing errors. This transition marked significant progress in user accessibility and programming practicality .

Maintainability ensures that software can be easily updated and corrected over time, while portability allows software to function across different platforms. Both are crucial for reducing long-term costs, enabling code reuse, and ensuring that software can adapt to changing technological environments, thus extending its usability and lifespan .

Programming languages differ from natural languages in structure and vocabulary. Programming languages have strictly defined rules and limited vocabularies, which are essential for unambiguous communication with computers. Natural languages, being vague and context-dependent, are unsuitable due to their large, dynamic vocabularies and ambiguous rules .

Assemblers translate assembly language into machine code, making programs executable by the computer. Key functions include translating mnemonic codes to machine codes, checking for syntax errors, assembling instructions into memory for execution, linking subroutines, and generating machine-readable output .

A good programming language should be easy to use, portable, natural for applications, reliable, safe, and perform well. It should also support structured programming and maintainability. These features ensure that the language is accessible, versatile, dependable, and can produce efficient and safe applications while being easy to maintain .

You might also like