Sie sind auf Seite 1von 5

COMPUTER PROGRAM

A computer program is a set of commands that tells the CPU what to do. It is also called as software
or an application.

PROGRAMMING LANGUAGE
Programming language is a computer language, human-created language used to write instructions
for a computer. It is the language used for communicating with the computer. It is the set of rules
that provides the computer to perform certain operations. A language that is acceptable to a
computer system is called a computer language or programming language

PROGRAMMING
The process of writing instructions in such a language for an already planned program is called
coding or programming.

COMPUTER LANGUAGE CLASSIFICATIONS


All computer languages can be broadly classified into the following categories:
 Low-Level Language
o Machine Language (1st Generation Language)
o Assembly Language (2nd Generation Language)
 High-Level Language
o Procedural-oriented Language (3rd Generation Language)
o Problem-oriented Language (4th Generation Language)
o Natural Language (5th Generation Language)

LOW - LEVEL LANGUAGE


 Oldest programming language
 Use of binary numbers (1s and 0s)
 Directly controls CPU, Memory, and registers
 Two types – Machine language and Assembly language

(1) MACHINE LANGUAGE


It is the first generation language (1GL). It is a language computer can understand. It is composed
of 0’s and 1’s. The machine language of a computer is normally written as strings of binary 1s and
0s. This type of program or source code written in binary form is called “Machine Code”.

Example: To write an instruction ADD 2 and 3 then we may have to write 01100001(i.e. ADD)
00000010(i.e. 2) and 00000011(i.e. 3)

Advantages of Machine Language


 Program written in machine language can be executed very fast by the computer because
no translation is required.
 It is the language of the computer
 It operates directly on hardware levels
Limitations of Machine Language
 Difficult to write, even if one bit change whole meaning may change.
 Lots of inputs required even for doing very small program.
 Because the internal design of every type of computer is different from every other type of
computer, the machine language also differs from computer to computer. (i.e. machine
dependent language)
 Writing a program in machine language is so difficult and time consuming that it is rarely
used today.
 Programmer need to know the track of memory locations

(2) ASSEMBLY LANGUAGE


Use alphanumeric mnemonic codes, instead of numeric codes for the instruction while writing
source code. These symbolic languages must be translated to machine language using assembler.
They are called as second generation language (2GL).

Example: MOV AX, 08


MOV BH, 30
MOV CX, 05
ADD AX, BH, CX

Advantages of Assembly Language


 Assembly languages are easier to understand and use.
 Less effort needed to write a program
 Easier to understand the mnemonics
 Programmers need not keep the track of the memory locations
 Programs can be revised quite easily

Limitations of Assembly Language


 Due to their close correspondence with machine language, different assembly languages
had to be developed for each type of CPU (i.e. they are processor dependent)
 Programs written in one system could not be run on other systems without introducing
significant changes.
 It is not a user-friendly language
 Programmers have to write a long sequence of instructions even for a small program
 An ‘assembler’ is needed to convert the assembly language to machine language
 Slow execution speed than machine language

ASSEMBLER
The assembler is program that translates an assembly language program into an equivalent
machine language. The assembly language program is referred to as “Source Program” whereas;
the machine language program is referred as “Object Program”. Assembler also assembles the
machine language programs into main memory of the computer and makes it ready for execution.
ASSEMBLY MACHINE
LANGUAGE ASSEMBLER LANGUAGE

Source Program Object Program


Fig: Assembler

HIGH-LEVEL LANGUAGE
High-level languages were designed to overcome their limitation such as machine dependent and
machine level coding. They are similar to written English. Their syntax is more like a human
language.

Advantages of High-level language


1. Machine independence: A program written in a high-level language can be executed on
many different types of the computers.
2. Easier to learn and use: High-level languages are easier to learn, because they are similar to
the natural language used by us in our day-to-day life.

3. Fewer errors: While programming in a high-level language, a programmer need not worry
about how and where to store the instructions and data of the program, and need not write
machine-level instructions for the steps carried out by the computer.
4. Lower program preparation cost: Writing programs in high-level languages require less
time and effort, which ultimately lads to lower program preparation cost.
5. Better documentation: The statements of program written in a high-level language are very
similar to the natural language statement use d by us in our day-to-day life. Hence a
programmer familiar with the problem domain can easily understand them. As a result, very
few, or practically no separate comment is required in program written in high-level language.
6. Easier to maintain: Programs written in high-level language are easier to maintain, they are
easier to understand, and hence, it is easier to locate, correct and modify instructions as and
when desired.

Disadvantages of High-level language


 More time to execute
 No direct mechanism to control computer hardware.
 Programs execute more slowly.
 The languages use computer resource less efficiently.
 A compiler is needed to translate high-level language into machine language
 A set of rules must be followed when writing the codes

High level languages are of three types:


 Procedural-Oriented Languages
 Problem-Oriented Languages
 Natural Languages

(3) PROCEDURAL- ORIENTED LANGUAGE


General-purpose programming languages are called procedural languages or third generation
language (3GL). They are languages such as Pascal, BASIC, COBOL and FORTAN, which are
designed to express the logic, the procedure, of a problem. Because of their flexibility, procedural
languages are able to solve a variety of problems.

Advantages of Procedural - Oriented language


 Easier to work as program statement resembles English-like phrases
 Machine-independent codes
 Once coded, it is easy to modify the program

Disadvantages of Procedural - Oriented language


 Programs execute more slowly
 These type of languages use computer resources less efficiently
 They use a text environment for programming

(4) PROBLEM- ORIENTED LANGUAGE


This is also known as 4GL. This is one step ahead from 3GL. These are result oriented and included
database query language. There are fewer options for programmers, but the programs are mush
easier to write than in lower level languages. 4GL programs are also needed to be translated either
by compiler or interpreter. In fact, 4GL cannot be used for all-purpose. They are dedicated for
some particular application developments. Example of 4GL is C, C++, SQL (structured Query
language), Delphi, ASP, PHP, VB.NET, VisualAge, etc.

COMPILER
Since computer can directly execute only machine language programs, a high-level language
program must be converted into its equivalent machine language program before it can be executed
on the computer. This is done with the help of translator program, which is known as a compiler.
A compiler is a translator program, which translates a high-level languages program into its
equivalent machine language program. Compiler is language dependent. FORTAN compiler can’t
compile COBOL program. In additional to translating, compiler also automatically detects and
indicates certain type of errors in source programs.

High Level Machine


Language COMPILER Language

Source Program Object Program


Fig: Compiler
INTERPRETER
An interpreter is another type of translator, which is used for translating programs written in high-
level languages. The working principle is different from that of compiler in the sense that
interpreter reads each line at a time and execute. So result is program execution not an object
program. As compared to compiler, error is detected and brought to the attention as soon as the
program is interpreted. The main disadvantage of the interpreter is that they are slower than
compiler. Both interpreter and compiler can be combined. Interpreter debug program and then
after a bug-free state is reached, the program are compiled.

High Level Machine


INTERPRETER
Language Language

Source Program Object Program


Fig: Interpreter

LINKER
Linker is a program that combines all the object program and library program collectively to
convert them to final executable program. Linkers are found in high-level languages like C, C++,
VC++, Java, etc.

High Level COMPILER Object Library


Language Program Program

Source Program

LINKER

Machine
Language

Object Program

Fig: Linker

Das könnte Ihnen auch gefallen