1.5 Computer Languages, Compiler, Interpreter & Assembler
1.5 Computer Languages, Compiler, Interpreter & Assembler
Programming Languages
Computer Languages and
Software is written in one of many programming
Compiler, Interpreter &
●
1
1/2/2023
Broad Classification of
Computer Languages
Machine Language
Machine language
• The fundamental language of the computer’s
Assembly language processor, also called Low Level Language.
High-level language • All programs are converted into machine language
before they can be executed.
• Consists of combination of 0’s and 1’s that
represent high and low electrical voltage.
In Binary In Decimal
Machine Dependent
(Difficult to read and understand) (Easier to read and understand) Difficult to program
Error prone
Difficult to modify
2
1/2/2023
Assembly/Symbolic Language
Assembly Language
Programming language that overcomes the limitations
of machine language programming by:
• A low level language that is similar to
Using alphanumeric mnemonic codes instead of numeric
machine language. codes for the instructions in the instruction set
e.g. using ADD instead of 1110 (binary) or 14
(decimal) for instruction to add
Allowing storage locations to be represented in form of
• Uses symbolic operation code to represent alphanumeric addresses instead of numeric addresses
e.g. representing memory locations 1000, 1001, and 1002 as
the machine operation code. FRST, SCND, and ANSR respectively
Providing pseudo-instructions that are used for
instructing the system how we want the program to be
assembled inside the computer’s memory
e.g. START PROGRAM AT 0000; SET ASIDE AN ADRESS FOR
FRST
3
1/2/2023
4
1/2/2023
20
5
1/2/2023
Compiler Compiler
Program P1 in
High-level Machine Compiler for
Input Output high-level Machine code
language Compiler language language L1
language L1 for P1
program program
6
1/2/2023
Compiler Linker
(Continued from previous slide..)
For a large software, storing all the lines of
Compiler for
language L1 Machine code for Executed on program code in a single source file will be:
on computer A P1 that will run computer A
on computer A
– Difficult to work with
– Difficult to deploy multiple programmers to
Program P1 in high-
level language L1 Same results concurrently work towards its development
obtained
– Any change in the source program would require
the entire source program to be recompiled
Compiler for Machine code for
Executed on
language L1
on computer B
P1 that will run on
computer B
Hence, a modular approach is generally
computer B
adapted to develop large software where the
Illustrating the machine independence characteristic of a software consists of multiple source program
high-level language. Separate compilers are required for the files
same language on different computers
No need to write programs for some modules as it
might be available in library offering the same
functionality (Continued on next slide)
Linker Interpreter
(Continued from previous slide..)
7
1/2/2023
Interpreter
(translates and
High-level language executes
program Input Output Result of
statement-by- program
(Source Program) statement) execution
8
1/2/2023
language
9
1/2/2023
FD DATA_FILE 01 OUTPUT_RECORD.
05 FILLER PICTURE X.
RECORD CONTAINS 80 CHARACTERS
05TITLE PICTURE X(25).
LABEL RECORD IS OMITTED 05 SUM PICTURE 9(10)V99.
DATA RECORD IS INPUT_DATA_ 05 FILLER PICTURE X(94).
RECORD. WORKING_STORAGE SECTION.
77MESSAGE PICTURE X(25)
VALUE IS “THE SUM OF GIVEN NUMBERS=”.
01 INPUT_DATA_RECORD.
05 NPICTURE 9(6)V99. PROCEDURE DIVISION.
05 FILLER PICTURE X(72). OPEN_FILES.
OPEN INPUT DATA_FILE.
OPEN OUTPUT OUTPUT_FILE.
FD OUTPUT_FILE
RECORD CONTAINS 132 CHARACTERS INITIALIZATION.
LABEL RECORD IS OMITTED MOVE SPACES TO OUTPUT_RECORD.
MOVE ZERO TO SUM.
DATA RECORD IS OUTPUT_RECORD.
10
1/2/2023
11
1/2/2023
/* PROGRAM TO COMPUTE THE SUM OF 10 NUMBERS */ Named C++ as ++ is increment operator and C
/* Directives to include standard library and header */
#include <stdlib.h>
language is incremented to its next level with C++
#include <stdio.h> Developed by Bjarne Stroustrup at Bell Labs in the
/* Main function starts here */
void main ( )
early 1980s
{ Contains all elements of the basic C language
/* Declaration of variables */
float Sum = 0.0, N = 0.0; Expanded to include numerous object-oriented
int Count = 0; programming features
for (Count = 0; Count < 10; Count++)
{ Provides a collection of predefined classes, along with
printf(“\nGive a number:”); the capability of user-defined classes
scanf(“%f”, N);
Sum += N;
}
printf(“THE SUM OF GIVEN NUMBERS = %f”, &Sum);
}
Java C# (C Sharp)
12
1/2/2023
RPG LISP
Simplicity
Stands for StriNg Oriented symBOlic
Language Naturalness
Used for non-numeric applications Abstraction
Powerful string manipulation features Efficiency
Widely used for applications in the area of Structured
text processing Programming Support
Compactness
Locality
Extensibility
Suitability to its
environment
13
1/2/2023
Key Differences between High level Key Differences between High level
and Low level Languages and Low level Languages
S.N S.N
o. High Level Language Low Level Language o. High Level Language Low Level Language
14
1/2/2023
● A "counter object," for instance, might be used to The logic behind using OOP is that much of the
count visitors to a web page. Its behaviors could real world is made up of objects
include resetting to zero or displaying its current Essence of OOP is to solve a problem by:
value.
Identifying the real-world objects of the
● An important benefit of object-oriented
problem
programming is modularity, so that an object can
be independently maintained, reused, or replaced if Identifying processing required of them
it breaks down or causes problems. Creating simulations of objects, processes,
● Also, programmers have no need to understand the and their communications
object's inner workings - only the rules that
determine how other objects can interact with it.
15