COMPUTER PROGRAM AND LANGUAGES New
COMPUTER PROGRAM AND LANGUAGES New
INTRODUCTION :-
The Computers work on set of instructions called as computer program, which clearly specifies
the way to carry out a task.
A person who is responsible for designing, writing and modifying computer programs is known
as a computer programmer. Broadly, programmers can be classified into two categories-
system programmers : System programmers write programs, which provide interface and
functionality to the hardware component. These programs help the computer to boot or facilitate
its general functionality.
application programmers :- An application programmer writes programs to fulfill a specific
task such as inventory control and payroll system.
DEVELOPING A PROGRAM
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, to design a program, a programmer
must determine three basic rudiments:
The program development cycle includes following phages. The following figure shows Program
Development lifecycle.
1
1. Problem Analysis: In this phase the problem is analyzed precisely and completely.
2. Task Analysis: After analyzing the problem, the developer needs to develop various
solutions to solve the given problem. From these optimum solution is chosen, which can
be solved more economically.
3. Algorithm Development: After selecting the appropriate solution an algorithm is
developed which depicts the solution in logical steps.
4. Algorithm Testing: Before converting the algorithms into actual code it should be
checked for accuracy. The purpose of this test is to identify logical errors at early stage.
5. Coding: Once the all design considerations are over coding of the program starts.
Depending on application domain and available resource a programmer cam write
programs in machine, assembly or high level languages.
6. Testing and Debugging: It is not unusual for the initial program code to contain errors.
These errors may be in the form of logical errors (semantic errors) or due to incorrect use
of programming language (grammatical errors also known as syntax errors). A program
compiler and programmer designed test data machine test the code for syntax errors.
7. Documentation: 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.
8. Implementation: After documentation, the program is installed on the end user’s
machine. The user is also provided with all the essential documents to understand how
the program works.
9. Maintenance and Enhancement: After the program is implemented (loading and
executing the program on user’s computer), it should be properly maintained by taking
care of the changing requirements of its users and system.
Computer Languages
The languages, which the user employs is not used to interact with the computers is known as
computer or programming languages. The process of using such languages to instruct the
computer is known as programming or coding.
In the initial years, languages were developed for specific purposes, which limited their scopes.
However, as the computer revolution spread affecting common man, the languages needed to be
moulded to suit all kinds of applications. Every new language inherited certain features from
existing languages and added its own features. The chronology of development in programming
languages is given below:
2
The first computer program was made by Lady Lovelace Ada Augusta in 1843 for an
analytical engine application.
Konrad Zuse, a German, started a language design project in 1943. He finally developed
Plan Kalkul, programming calculus, in 1945. The languages supported bit, integer,
floating-point scalar data, arrays and record data structures.
The languages that was first implemented was short code for the Binac (later transferred
to univac) in 1949 by J. W. Mauchly.
In early 1950s, Grace Hopper and his team developed A-0 languages. During this period,
assembly languages were introduced.
In 1954 John Backus developed coding for IBM 701 systems. The purpose was to use
simple arithmetic expressions and to speed up the coding.
John Backus developed FORTRAN (FORmula TRANslator) in 1957. The FORTRAN
data are oriented around numerical calculations. It was a major step towards development
if full-fledged programming languages including control structures, conditional loops and
input and output statements.
ALGOL60 was developed by GAMM (German Society of Applied Mathematics) and
ACM(Association of Computing Machinery) in 1960.
COBOL (Common Business Oriented Languages) was developed for business purpose
by US department of defense in 1960.
BCPL, BASIC, PASCAL and B were developed in late 1960s and early 1970s.
In early 1970s Dennis Ritchie developed C at bell laboratories using features of B
languages.
C++ was developed by Bjarne Stroustrup in early 1980s, extending the features of C and
introducing object-oriented features.
Java, originally called oak, was developed by Sun Microsystems of USA in 1991 as
general purpose languages. Java was designed for the development of software for
consumer electronic devices. It was a simple, reliable, portable and powerful language.
Computers understand only one language, that is binary language or the language of 0s and 1s.
binary language is also known as machine or low level language.
3
High-level languages: These languages are written using a set of words and symbols
following some rules similar to a natural languages such as English. The programs are
converted into machine readable languages known as source languages.
The first languages was binary, also known as machine languages, which was used in the earlier
computers and machines. The computers are digital devices, which have only two states, ON and
OFF (1and 0). Hence, they can understand only two binary codes, that is, 1 and 0. Therfore,
every instruction and data should be written using 0s and 1s. machine languages is also known as
the ‘native’ languages of the computer because this system of codes is directly understood by
the computer.
Lady Lovelance Ada Agusta suggested binary numbers for computer storage instead of decimals.
An instruction in machine language consists of two parts. The first part is the command or an
operation, which instructs the computer what functions are to be performed. The second part of
the instruction is operand, which instructs the computer where to find or store the data on which
the desired operation is to be performed.
A binary program is a long list of instructions that are executed by the CPU. Each computer has
its own set of instructions based on its architecture. Machine language may differ from one
computer to another.
Advantages of machine languages: even though machine language is not a user friendly language
it offers certain advantages as follows.
Translation Free: it is the only languages that the computers can directly execute without
the need for conversion .
High speed: since no conversion is needed, the application developed using machine
languages are extremely fast.
Machine dependent: an application developed for a particular type of computer may not
run on the other. This may prove costly as well as difficult for the organization.
Complex languages: machine languages is very difficult to read and write. Since all the
data and instructions must be converted to binary code, it is impossible to remember the
instructions.
Error prone: since the programmer has to remember all the opcodes and the memory
location, it is bound to be error prone.
4
Tedious: the programming becomes too complex to modify, has to rewrite the entire
program. Therefore, it is very tedious and time-consuming.
It was developed in early 1950s and its main developer was IBM. Assembly Language allows the
programmer to interact directly with the hardware. This languages 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.
Assembly languages is a group of languages. Each processor family has its own assembly
languages.
The basic unit of an assembly languages 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
languages program consists of four columns called fields. The general format of an assembly
instruction is:
[….]brackets indicate that enclosed specification may or may not appear in statement.
For example:
The original assembly languages program is also known as the source code, while the final
machine languages program is designated as the object code. If an assembly languages program
5
needs to be changed or corrected, it is necessary to make the changes to the source code and then
reassemble it to create a new object program. The function of an assembler are as follows:
It allows the programmer to use mnemonics while writing source code program, which
are easier to read and follow.
It allows the variables to be represented by symbolic names, not as memory locations.
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 diagonstic messages on
syntax errors.
It assembles all the main memory for execution.
In case of large assembly programs, it also provides linking facility among the
subrountines.
It facilities the generation of output on required output medium.
Easy to understand and use: the program written in assembly languages are much
easier to understand and use as compared to its machine language counterpart.
Les error prone: since, mnemonic codes and symbolic addresses are used, the
programmer did not have 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.
Efficiency: assembly programs can run much faster and use less memory and other
resources than a similar program written in a high-level language.
More control on hardware: assembly languages also gives direct access to key machine
features essential for implementing certain kinds of low level routines.
Machine dependent: programs written in these languages are not portable to other,
incompatible systems. This makes it a low level languages.
Harder to learn: the source code for an assembly language is cryptic and in a very low
machine specific form.
Slow development time: assembly generated applications are slower to develop as
compared to high level language based application.
Less efficient: a program written in assembly language is less efficient. Every assembly
instruction has to be converted into machine languages. The execution of the assembly
languages program takes more time than machine language program.
No standardization : assembly languages cannot be standardized because each type of
computer has a different set and therefore a different assembly languages.
6
No support for modern software engineering technology: they work with machine
level specification, not with abstractions. Assembly languages does not provide inherent
support for safety-critical systems. It provides very little opportunity for reuse.
Due to widespread use of computer, early 1960s saw the emergence of the third generation
programming languages (3GL). Languages such as COBOL, FORTAN, BASIC and C are
example of 3GLs and are considered high level languages.
Programs written using these languages can be machine independent. A single high level
statement can substitute several instructions in machine language. High level programs may be
used with different types of computers with little or no modification.Using a high level
languages, programs are written in a sequence of statements that impersonates human thinking to
solve a problem.
It is necessary to convert the high level languages programs into machine languages codes. This
is achieved by using languages translators or languages processors, generally known as
compilers, interpreters or other routines that accepts statements in one language and procedures
equivalent statements in machine language.
Compiler : a compiler is a kind of translator that translates a program into another program,
known as target languages. Usually, the term ‘compiler’ is used for language translator of high
level languages. The compiler replaces single high level statement with a series of machine
languages instruction. A compiler usually resides on a disk or other storage media. When a
program is to be complied, its compiler is loaded into the 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 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 the errors are rectified.
Program
compilerprogram
(source code) error messages
Working of compiler
Interpreter:
7
An interpreter is also a language translator and translates high level languages guage into
machine languages. It translates a statement in a program and execute the statement immediately,
that is , before translating the next source language statement. When an error encountered in the
program, the execution of the program is halted and an error message is displayed. Similar to the
compilers, every interpreted languages such as BASIC and LISP has its own interpreters.
Program Interpreter
-uted statement
Working of interpreter
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.
8
file, which can be executed anytime time it is executed from the source
without translating again. program.
Loader: loader is a part of the operating system that brings an executable file residing on the
disk into the memory and starts running. 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 file as an output. A
loader performs four basic tasks as follows:
Absolute Loader: it loads the file into the memory at the location specified by the
beginning portion 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.
Relocating Loader: this loader loads the program in the memory, altering the various
addresses as required to ensure correct referring. The decision as to where in the memory
the program is placed is done by the operating system, not by the file header.
Readability: since, high level languages are close to natural languages, they are easier to
learn and understand. Even a common man use it without much difficulty.
Machine Independent: high level languages 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: 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.
Easier to maintain: as compared to low level languages, the programs are easy to
modify and maintain
Low development cost: high level languages permit faster development of programs.
Cost of writing a program is nearly constant for each line of code, regardless of the
languages.
Easy documentation: since, the statement written in HLL are similar to natural
languages, they can be easily understood by the users.
9
Disadvantages of high level languages:
Poor control on hardware: sometimes the application written in high level languages
cannot completely harness the total power available at hardware level.
Less efficient: the HLL application are less efficient as far as computation time is
concerned. high level languages must be created and sent through another processing
program known as a compiler. This process of translation increases the execution time of
an application.
FORTAN
COBOL
BASIC
PASCAL
C
C++
Java
PROLOG
LISP
Fourth generation languages (4GLS) have simple, English like syntax rules, commonly used to
access databases. 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 the other to
perform a task. In other words, the computer is instructed what it must do rather than how to do.
The non procedural method is easier to write, but has less control over how each task performed.
4GLS sacrifice computer efficiency to make programs easier to write. Hence, they require more
computer power and processing time.
This saves time and allows professional programmers to perform more complex tasks. The 4GLs
are divided into the following three categories.
Query languages: they follow the user to retrieve information from databases by
following simple syntax rules.
Report generators: they produce customized reports using data stored in a database.
The user specifies the data to be in the report, the format of the report and whether any
10
subtotals and totals are needed. Report specification are selected from pull-down
menus, making report generators very easy to use.
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.
Advantage of 4GLs: the main advantage of 4GLs is that a user can create an application in a
much shorter time for development and debugging. It does not require the programmer to
provide the logic to perform a task. Therefore, lot of programming efforts are saved as compared
to 3GLs. Use of procedural templates and data dictionaries allow automatic type checking and
this results in fewer errors. Using application generators, the routine tasks are automated.
Disadvantages of 3GLs: since programs written in a 4GL are quite lengthy, they need more disk
space nd a larger memory capacity as compared to 3GLs. These languages are flexible. These
language cannot directly utilize the computer power available at hardware level as compared to
other levels of languages.
They are just the conceptual view of what might be the future of programming languages. These
languages will be able to process natural languages. The computer 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 languages to communicate with the computers.
11
thinking through algorithms and means of expressing those algorithms through
flowcharts. That even a novice user can understand them easily without learning any
programming languages.
Reliability: reliability is concerned with making a system failure-free, and thus is
concerned with all possible errors. The language should have support of error detection as
well as prevention. It should make some kind of errors impossible. The languages should
also be able to detect and report errors in the program. The languages should provide
reliability by supporting explicit mechanisms for dealing with problems that are detected
when the system is in operation.
Safety: safety 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
should be able to recover from any situation that might lead to a mishap or actual system
hazard. Languages can facilitate this through such features as built in consistency
checking and exceptional handling.
Performance: performance, means that the languages should not only be capable of
interpreting with the end users, but also with the hardware. The languages should also
support software engineering mechanism, discouraging or prohibiting poor practices and
supporting maintenance activities.
Cost: cost component is a primary concern before deploying a language at a commercial
level. It includes several codes such as follows:
Program execution and translating cost.
Program creation, testing and usage cost.
Program maintenance cost.
Promote structured programming: a good language should be capable of supporting
structured programming. By nature, structured programming facilities ease in
understanding the code, a program is easier to create, debug and maintain. A structured
program also helps the programmers to visualize the problem in a logical way, thereby
reducing the portability of errors in the code.
Compact code: a good language should also promote compact coding, that is, the
intended operations should be coded in a minimum number of lines.
Maintainability: 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 structure of the code. If the original codes are written in an organized way,
then it would be easy to modify or add new changes.
Reusability: the languages should facilitate the adaptation of code for use in other
application. Code is reusable when it is independent of other codes. It is very common,
for example, to reuse common operations on the structure, these abstract data types are
easy to reuse.
12
Provides interface to other language: interface to other languages refer to the extent to
which the selected language supports interfacing feature to other languages. This type of
support can have a significant impact on the reliability of the data, which is exchanged
between units of different languages, without specific language support.
Concurrency support: concurrency support refers to extent to which inherent language
supports the construction of code with multiple threads of control(also known as parallel
processing). Multiple threads of control are very useful for real time systems and those
running on architecture with multiple processors.
Standardization: standardization means the extent to which the languages definition has
been formally standardized. Nonstandard languages may soon become obsolete. Lack of
appropriate support compromises developer productivity and system quality.
13