0% found this document useful (0 votes)
44 views15 pages

1.5 Computer Languages, Compiler, Interpreter & Assembler

The document provides an overview of programming languages, categorizing them into machine language, assembly language, and high-level languages. It explains the roles of compilers and interpreters in translating code, and discusses various programming languages such as FORTRAN, COBOL, BASIC, Pascal, and C, along with their applications and examples. Additionally, it highlights the advantages and limitations of different programming languages and their respective uses in software development.

Uploaded by

rajsinghvatsalya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views15 pages

1.5 Computer Languages, Compiler, Interpreter & Assembler

The document provides an overview of programming languages, categorizing them into machine language, assembly language, and high-level languages. It explains the roles of compilers and interpreters in translating code, and discusses various programming languages such as FORTRAN, COBOL, BASIC, Pascal, and C, along with their applications and examples. Additionally, it highlights the advantages and limitations of different programming languages and their respective uses in software development.

Uploaded by

rajsinghvatsalya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1/2/2023

Programming Languages
Computer Languages and
Software is written in one of many programming
Compiler, Interpreter &

languages, which are artificial languages that


Assembler provide the instructions for the computer about
how to accept information, process it, and provide
output.
● Figure lists some common programming languages
along with a few that are nearly dead. Some older
Dr. Anoop Kumar Gupta languages survive in legacy systems-applications
MAIT that are still in use because the applications that
were created with them work reasonably well and
would be costly to replace
1

Programming Languages Examples of programming languages

● The source code includes all the statements that


the programmers write to communicate with the
computer and provide instructions. You can see the
source code for a web page by right-clicking the
page in your browser and selecting "view source."
● A simple web page might only be a few lines long,
but a complex information system might contain
millions of lines of code.

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.

A Sample Machine Language Program Advantages & Limitations of


Machine Language

001000000000001100111001 10001471 Advantage


001100000000010000100001 14002041
011000000000011100101110 30003456  Can be executed very fast
101000111111011100101110 50773456
000000000000000000000000 00000000 Limitations

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

Assembler An Example of Assembly


Language Program

 Software that translates as assembly language


program into an equivalent machine language program
Mnemonic Opcode Meaning
of a computer
HLT 00 Halt, used at the end of program to stop
CLA 10 Clear and add into A register
Assembly Input Output Machine
language language ADD 14 Add to the contents of A register
program Assembler program SUB 15 Subtract from the contents of A register
STA 30 Store A register
One-to-one correspondence
(Source Program) (Object Program)
A subset of the set of instructions supported by a computer

3
1/2/2023

An Example of Assembly An Example of Assembly


Language Program Language Program

START PROGRAM AT 0000


START DATA AT 1000 Symbolic name Memory location
SET ASIDE AN ADDRESS FOR FRST
SET ASIDE AN ADDRESS FOR SCND FRST 1000
SET ASIDE AN ADDRESS FOR ANSR SCND 1001
CLA FRST ANSR 1002
ADD SCND
STA ANSR
HLT Mapping table set up by the assembler for the data items
of the assembly language program

Sample assembly language program for adding two numbers and


storing the result

An Example of Assembly Advantages of Assembly Language


Language Program Over Machine Language
Memory Contents Comments  Easier to understand and use
location
Opcode Address
 Easier to locate and correct errors
0000 10 1000 Clear and add the number stored at FRST to A register
0001 14 1001 Add the number stored at SCND to the contents of A  Easier to modify
register
0002 30 1002 Store the contents of A register into ANSR  No worry about addresses
0003 00 Halt
 Easily relocatable
-
-  Efficiency of machine language
-
1000 Reserved for FRST
1001 Reserved for SCND
1002 Reserved for ANSR

Equivalent machine language program for the assembly language program

4
1/2/2023

Limitations of Assembly Language Typical Uses of Assembly Language

 Machine dependent  Mainly used today to fine-tune important parts of


programs written in a high-level language to improve
 Knowledge of hardware required
the program’s execution efficiency
 Machine level coding

Assembly Languages with


Macro Instructions
High Level Language
 Any assembly language instruction that gets translated
into several machine language instructions is called a
macro instruction
• Computer (programming) languages that are
 Several assembly languages support such macro
instructions to speed up the coding process easier to learn.
 Assemblers of such assembly languages are designed to
produce multiple machine language instructions for each • Uses English like statements.
macro instruction of the assembly language
• Examples are C ++, Visual Basic, Pascal,
Fortran and …....

20

5
1/2/2023

High-Level Languages Compiler

 Machine independent Translator program (software) that


 Do not require programmers to know translates a high- level language
anything about the internal structure of program into its equivalent machine
computer on which high-level language language program
programs will be executed
Compiles a set of machine language
 Deal with high-level coding, enabling the
instructions for every program
programmers to write instructions using
English words and familiar mathematical instruction in a high-level language
symbols and expressions

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

Program P2 in Compiler for


One-to-many correspondence
(Source (Object high-level language L2 Machine code
Program) Program) language L2 for P2

A computer supporting languages L1 and L2

Illustrating the requirement of a separate compiler for each


high-level language supported by a computer

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..)

Interpreter is a high-level language


 Each source program file can be translator
independently modified and compiled to
create a corresponding object program file Takes one statement of a high-level
 Linker program (software) is used to language program, translates it into
properly combine all the object program machine language instructions
files (modules) Immediately executes the resulting machine
 Creates the final executable program (load language instructions
module)
Compiler simply translates the entire source
program into an object program and is not
involved in its execution

7
1/2/2023

Role of an Interpreter Language Translators

Interpreter
(translates and
High-level language executes
program Input Output Result of
statement-by- program
(Source Program) statement) execution

Advantages of High-Level Languages Limitations of High-Level Languages

Machine independent  Lower execution efficiency


Easier to learn and use  Less flexibility to control the computer’s
CPU, memory and registers
Fewer errors during program
development
Lower program preparation cost
Better documentation
Easier to maintain

8
1/2/2023

FORTRAN A Sample FORTRAN Program

 Stands for FORmula TRANslation C FORTRAN PROGRAM TO COMPUTE


C THE SUM OF 10 NUMBERS
 Originally developed by John Backus and his team at
SUM = 0
IBM followed by several revisions
DO 50 I = 1, 10
 Standardized by ANSI (American National Standards READ (5, 10) N
Institute) as FORTRAN-77 and FORTRAN-90 SUM = SUM + N
 Designed for solving scientific & engineering problems 50 CONTINUE
WRITE (6, 20) SUM
 Oriented towards solving problems of a mathematical 10 FORMAT (F6.2)
nature 20 FORMAT (1X, ’THE SUM OF GIVEN NUMBERS = ’,
 Popular language amongst scientists and engineers F10.2)
STOP
END

COBOL A Sample COBOL Program

 Stands for COmmon Business Oriented IDENTIFICATION DIVISION.


PROGRAM_ID. SUMUP.
Language AUTHOR. P K SINHA.
* THIS PROGRAM COMPUTES AND PRINTS
 Originally developed started under Grace * THE SUM OF GIVEN NUMBERS.
Hopper followed by COnference on DAta ENVIROMENT DIVISION.
SYstems Languages (CODASYL) CONFIGURATION SECTION.
SOURCE_COMPUTER. BURROUGHS_6700.
 Standardized by ANSI as COBOL-74, COBOL- OBJECT_COMPUTER. BURROUGHS_6700.
INPUT_OUTPUT SECTION.
85, and COBOL-2002 FILE_CONTROL.
SELECT DATA_FILE ASSIGN TO DISK.
 Designed for programming business data SELECT OUTPUT_FILE ASSIGN TO PRINTER.
processing applications
DATA DIVISION.
 Designed to have the appearance and structure FILE SECTION.
of a business report written in English, hence
often referred to as a self-documenting (Continued on next slide)

language

9
1/2/2023

A Sample COBOL Program A Sample COBOL Program


(Continued from previous slide..) (Continued from previous slide..)

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.

(Continued on next slide)

A Sample COBOL Program BASIC


(Continued from previous slide..)

PROCESS_LOOP.  Stands for Beginners All-purpose Symbolic


READ DATA_FILE AT END GO TO Instruction Code
PRINT_PARA.
ADD N TO SUM.  Developed by Professor John Kemeny and
GO TO PROCESS_LOOP. Thomas Kurtz at Darmouth College in the United
States
PRINT_PARA.
MOVE MESSAGE TO TITLE.  Standardized by ANSI as BASIC-78
WRITE OUTPUT_RECORD.
 Designed to be an interactive language and to
END_OF_JOB. use an interpreter instead of a compiler
CLOSE DATA_FILE.
 Simple to implement, learn and use language.
CLOSE OUTPUT_FILE.
STOP RUN. Hence, it is a widely used language on personal
computers
 Flexible and reasonably powerful language and
can be used for both business and scientific
applications

10
1/2/2023

A Sample BASIC Program Pascal

5 REM PROGRAM TO COMPUTE  Named after the famous seventeenth-


6 REM THE SUM OF 10 NUMBERS
10 LET S = 0 century French mathematician Blaise Pascal
20 FOR I = 1 TO 10  Developed by Professor Nicklaus Wirth of Federal
30 READ N
40 LET S = S + N Institute of Technology in Zurich
50 NEXT I
60 PRINT “THE SUM OF GIVEN NUMBERS = ”; S
 Encourages programmers to write well-
70 DATA 4, 20, 15, 32, 48 structured, modular programs, instills good
80 DATA 12, 3, 9, 14, 44 program practices
90 END;
 Recognized as an educational language and is
used to teach programming to beginners
 Suitable for both scientific & business applications
 Has features to manipulate numbers, vectors,
matrices, strings, sets, records, files, and
lists

A Sample Pascal Program C


PROGRAM SUMNUMS (INPUT, OUTPUT);
(* PROGRAM TO COMPUTE THE SUM OF 10 NUMBERS *)
 Developed in 1972 at AT&T’s Bell laboratories, USA
by Dennis Ritchie and Brian Kernighan
(* DECLARATION OF VARIABLES *)
VAR SUM, N : REAL;
 Standardized by ANSI and ISO as C89, C90, C99
VAR I : INTEGER;  High-level programming languages (mainly machine
(* MAIN PROGRAM LOGIC STARTS HERE *) independence) with the efficiency of an assembly
BEGIN language
SUM := 0;
FOR I := 1 TO 10 DO
 Language of choice of programmers for portable
BEGIN systems software and commercial software packages
READ (N); like OS, compiler, spreadsheet, word processor, and
SUM := SUM + N; database management systems
END;
WRITELN (‘THE SUM OF GIVEN NUMBERS=’, SUM);
END;

11
1/2/2023

A Sample C Program C++

/* 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)

 Development started at Sun Microsystems in 1991 by a  Object-oriented programming language


team led by James Gosling developed by Anders Hejlsberg and released by
 Developed to be similar to C++ with fewer features to Microsoft as part of Microsoft’s .NET technology
keep it simple and easy to use initiative

 Compiled code is machine-independent and developed  Standardized by ECMA and ISO


programs are simple to implement and use  Syntactically and semantically very close to C++
 Uses just-in-time compilation and adopts various object-oriented features from
both C++ and Java
 Used in embedded systems such as hand-held devices,
telephones and VCRs  Compilers target the Common Language
Infrastructure (CLI) implemented by Common
 Comes in two variants – Java Runtime Engine (JRE) and Language Runtime (CLR) of .NET Framework
Java Software Development Kit (SDK)
 CLR provides important services such as,
memory management, exception handling,
and security

12
1/2/2023

RPG LISP

 Stands for Report Program Generator  Stands for LISt Processing


 Developed by IBM to meet customer requests  Developed in 1959 by John McCarthy of MIT
for an easy and economic mechanism for  Designed to have features for
producing reports manipulating non- numeric data, such
 Designed to generate the output reports as symbols and strings of text
resulting from the processing of common  Due to its powerful list processing
business applications capability, it is extensively used in the
 Easier to learn and use as compared to COBOL areas of pattern recognition, artificial
intelligence, and for simulation of games
 Programmers use very detailed coding sheets
to write specifications about input,  Functional programming language in which
calculations, and output all computation is accomplished by
applying functions to arguments

SNOBOL Characteristics of a Good


Programming Language

 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

Factors for Selecting a Language for Subprogram


Coding an Application

 Program written in a manner that it can be brought


 Nature of the application into use in other programs and used whenever
 Familiarity with the language needed without rewriting

 Ease of learning the language  Also referred to as subroutine, sub-procedure, or


function
 Availability of program development tools  Subprogram call statement contains the name of
 Execution efficiency the subprogram followed by a list of parameters
enclosed within a pair of parentheses
 Features of a good programming language  Intrinsic subprograms (also called built-in-functions)
are those provided with the programming language
 Programmer-written subprograms are written and
used as and when they are needed

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

It is programmer friendly It is a machine friendly It is complex to maintain


1. language. language. 5. It is simple to maintain. comparatively.

High level language is less Low level language is high


2. memory efficient. memory efficient. 6. It is portable. It is non-portable.

3. It is easy to understand. It is tough to understand. 7. It can run on any platform. It is machine-dependent.

It is complex to debug It needs compiler or It needs assembler for


4. It is simple to debug. comparatively. 8. interpreter for translation. translation.

14
1/2/2023

Key Differences between High level


and Low level Languages Object-oriented Programming
S.N
o. High Level Language Low Level Language ● Advances in programming languages make it easier
for developers to write reliable and easily
The low-level language maintained code.
is a programming ● For instance, object-oriented programming focuses
language that provides on "objects" rather than lists of instructions and
no abstraction from the routines to manipulate data.
Examples of high level hardware, and it is ● Programmers define the nature of the data each
languages are Python, represented in 0 or 1 object contains and also the kinds of operations or
C, C++, Java, COBOL forms, which are the behaviors it can do. The modular, reusable objects
5. etc. machine instructions. often simulate real-world objects along with the
various states and behaviors they display.

Object-oriented Programming Object-Oriented Programming Languages

● 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

You might also like