Unit 5 Programming Logic and Concept
Unit 5 Programming Logic and Concept
(4GL)
(3GL) Procedural (5GL) Natural
Machine level Assembly level Problem oriented
Language language
language
Low-Level Languages
Low-level computer languages are machine dependent language. The
language designed for one computer is not suitable for other computer.
These languages are not portable. There are two types of low-level
languages:
1. Machine Language:
2. Assembly Language:
• Machine language:
• Machine language is the lowest and most elementary level of
programming language and was the first type of programming language
to be developed. Machine language is basically the only language that a
computer can understand.
• The lowest level of programming language in which information is
represented as strings of 0s and 1s (binary digits or bits) is called
machine language.
• Every CPU has its own unique machine language.
Advantage Machine Language: Disadvantages Machine Language:
1. The only advantage is that 1. It is very difficult to program in
program of machine language run machine language. The
very fast because no translation programmer has to know details
program is required for the CPU. of hardware to write program.
2. It is directly understood by 2. It is difficult to debug the
the computer. program.
3. Machine language makes fast 3. Programs are not portable to
and efficient use of the computer. other computers.
4. It is machine dependent
Assembly Level Language: -
• The difficulties faced while writing a program in a machine language
led to the development of assembly language. It uses symbolic
notations to represent the instructions of the machine language. These
symbolic notations are called mnemonic codes. For example, ADD for
addition, SUB for subtraction etc.
• The program written in assembly language is called source program.
Source program translated into machine language by a translator
program is called object program. Computer viruses are mostly written
in Assembly language.
• Source Program=>Assembler=>Object Program
OP code Operand Comment
ADD A,B; Add B to A
Advantages of Assembly Level Language:
1) Simple to understand and use than machine language.
2) Easy to write programs.
3) Easier to debug programs than the programs of machine language.
Disadvantages of Assembly Level Language:
1) It is low level language so knowledge of hardware is required.
2) Programming is a lengthy and time consuming process in
assembly level languages.
High Level Languages(HLL):
• High-level computer languages use formats that are similar to English. The
purpose of developing high-level languages was to enable people to write
programs easily.
• High level languages are platform independent. They are portable.
• Example: FORTRAN (Formula Translation), BASIC (Beginners All-purpose
Symbolic Instruction Code),C,C++,JAVA,LISP,PROLOG,Python,etc.
• Procedural Oriented Language (3GL):
• General-purpose programming languages are called
procedural languages or third generation languages.
• They are languages such as Pascal, BASIC, COBOL, and
FORTRAN, 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 include: Disadvantages include:
1. The program statements are in 1. Program executes more slowly.
English and hence are easier to 2. They are mostly CUI based
work with. language.
2. Because of their English-like
nature, less time is required for
coding.
3. Programs are easier to
understand and modify.
4. The programming languages are
machine-independent.
Problem Oriented Language/Fourth Generation Language (4GL):
Fourth generation language, also known as problem oriented language, are high level
language designed to solve specific problems or develop specific applications such as
database, web based application,etc.
Fourth-generation languages may be categorized into several kinds of application
development tools:
• Personal computer application software
• Query languages and report generators
• Decision support systems and financial planning languages
• Application generators
It is more user-friendly and enhances programming efficiently with usage of English like
words and phrases, use of icons, graphical interface, and symbolic representation.
Dbase, PHP, JavaScript, ORACLE, etc. are the examples of 4GL
Advantages include: Disadvantages include:
1. Simplified the programming 1. Programs run slower than those
process. of earlier language because their
2. They possess friendly interface. machine code is longer and more
complicated to execute.
3. They are easier to use than
previously used high level 2. It requires more memory, disk
language. storage so more execution time
needed.
Natural Language (5GL):
Natural languages are still in development stages, but they promise to have
profound effect, particularly in the areas of artificial intelligence and expert
systems. Natural languages have two characteristics:
• They are designed to make the connections that humans have with
computers more naturals-more humanlike.
• They are designed to allow the computer to become “smarter”-to
actually simulate the learning process by remembering and improving
upon earlier information.
Two popular natural languages are LISP and PROLOG.
• Advantages include: • Disadvantages include:
• 1. It answers questions when • 1. It doesn’t recognize
given a human question. homonyms. E.g. RAM, Keyboard,
• 2. Language processing is Mouse
focused on developing efficient • 2. May require more
algorithm to process task. keystrokes
• 3. Relieves burden of learning • 3. May not show context
syntax
• Language Translator
• A language translator is a special type of
computer software that has the capacity of
translating the source code or program codes
into machine codes.
• It translate high level and assembly level
language into machine level language.
Assembler:
An assembler is language translator that converts programs written in
assembly language (source code) into machine language (object
code).The resulting program can be executed only when assembly
process is completed.
Source
Code
Assembler
Object Error
Code message
Compiler:
A compiler is software that converts programs written in high level language
(source code) into machine code (object code), whole program at a time. The
machine language code is called the object code and high level language code is
called Source code. Some programming languages which use compiler are
COBOL, C, C++, FORTRAN, etc.
Source
Code
Compiler
Object Error
Code message
Interpreter:
An interpreter is software that converts programs written in high level
language to machine language code, one instruction at a time. If there is
any error in any line, it is reported to the user. The most frequently used
interpreted language is BASIC. It requires less memory.
Source
Code
interpreter
Object Error
Code message
SN Compiler Interpreter
1 It translates entire program into machineIt translates one statement of a program at a time into
language at once. machine language.
2 Syntax errors are not known untilSyntax errors are known at each line, while writing the
compilation is at the end. program.
5 Compiler generates executable code. Interpreter does not generate executable code, each
statement is interpreted and then only executed.
6 It is appropriate for developing heavyIt is appropriate for developing light weight and small
weight and large application. application.
7 Example: C, C++, Pascal, FORTAN, etc. Examples: QBASIC, GWBASIC, PERL, etc.
Program Software
32 Blank 65 A
33 ! 66 B
34 “ 90 Z
48 0 97 a
49 1 98 b