Chapter 12-CL-2oP PDF
Chapter 12-CL-2oP PDF
Chapter 12-CL-2oP PDF
Computer Fundamentals
Pradeep K. Sinha
Priti Sinha
Chapter 12
Computer
Chapter 12: Computer Languages
Languages Slide 1/64
Learning Objectives
1
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Analogy with
Natural Languages
2
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Machine language
Assembly language
High-level language
Machine Language
3
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Machine Language
OPCODE OPERAND
(operation code) (address/location)
Instruction format
(Continued on next slide)
Machine Language
4
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
001000000000001100111001 10001471
001100000000010000100001 14002041
011000000000011100101110 30003456
101000111111011100101110 50773456
000000000000000000000000 00000000
In Binary In Decimal
(Difficult to read and understand) (Easier to read and understand)
Advantage
Limitations
Machine dependent
Difficult to program
Error prone
Difficult to modify
5
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Assembly Language
Assembly Language
6
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Assembler
One-to-one correspondence
(Source program) (Object program)
7
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Advantages of Assembly Language
Over Machine Language
Machine dependent
Knowledge of hardware required
Machine level coding
8
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
9
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
High-level Language
High-Level Languages
Machine independent
Do not require programmers to know anything about the
internal structure of computer on which high-level
language programs will be executed
Deal with high-level coding, enabling the programmers
to write instructions using English words and familiar
mathematical symbols and expressions
10
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Compiler
Compiler
Input Output
High-level language Compiler Machine language
program program
One-to-many correspondence
(Source program) (Object program)
11
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Separate Compiler for Each High-level
Language Supported
Program P1 in high-
level language L1 Same results obtained
12
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Syntax Errors
Illegal characters
Illegal combination of characters
Improper sequencing of instructions in a program
Use of undefined variable names
Edit
source program
Source program
Compile
source program
Syntax
No Generate
errors
detected? object program
13
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Linker
Linker
14
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Linker
Compilation
process
Prog-1.obj Prog-2.obj Prog-n.obj Object programs
Linking
process
Interpreter
15
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Interpreter
Interpreter
16
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Intermediate Language Compiler &
Interpreter
New type of compiler and interpreter combines the
speed, ease, and control of both compiler and
interpreter
Compiler first compiles the source program to an
intermediate object program
Intermediate object program is not a machine
language code but written in an intermediate
language that is virtually machine independent
Interpreter takes intermediate object program,
converts it into machine language program and
executes it
17
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Machine independent
Easier to learn and use
Fewer errors during program development
Lower program preparation cost
Better documentation
Easier to maintain
18
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Object-Oriented
Languages
19
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
20
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Example of Class, Instance, and
Inheritance
Person
Boy Man
Class B
(Sub-class of Object b
Class A) (Instance of B)
Inherits from A Class B
21
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Sr.
Element Meaning
No.
1 Abstraction Abstraction means that an objects characteristics are broken
into manageable chunks as defined and documented in its
class description.
2 Encapsulation Encapsulation stipulates that code and data are stored as one
unit. Encapsulation also enables selective or total information
hiding, since it can make portions of the code and data
inaccessible from outside the unit.
3 Modularity Modularity defines the unit reuse. These units group
abstractions together.
4 Hierarchy Hierarchy allows an objects behaviors to be refined
(subclasses) without recoding of the parent object (the
superclass). Some OO languages allow an object to have
more than one superclass, a feature that is known as multiple
inheritance. Inheritance hierarchies enable ranking/ordering
of abstractions.
5 Messages Messages, similar in use to function calls, are requests to
perform an operation on an instantiated object.
Some High-level
Languages
22
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
FORTRAN
COBOL
23
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
BASIC
Pascal
24
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
25
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Java
C# (C Sharp)
26
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
RPG
LISP
27
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
SNOBOL
28
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Characteristics of a Good
Programming Language
Simplicity
Naturalness
Abstraction
Efficiency
Structured Programming Support
Compactness
Locality
Extensibility
Suitability to its environment
29
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Subprogram
Subprogram
30
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Structure of a Subprogram
Subprogram header
sqrt (x)
1 2 subprogram header
subprogram body
7
5
31
Computer Fundamentals: Pradeep K. Sinha & Priti Sinha
Key Words/Phrases
Key Words/Phrases
SNOBOL
Source program
Sub-procedure
Subprogram
Subroutine
Symbolic language
Syntax error
Syntax rules
Programmer-written subprograms
32