0% found this document useful (0 votes)
3 views

Programming languages

Uploaded by

maha
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming languages

Uploaded by

maha
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

Module I

Jan 6, 2025 1
PROGRAMMING LANGUAGES

 A Programming Language consists of a set of vocabulary and


grammatical rules, to express the computations and tasks that
the computer has to perform.
 Programming languages fall into two categories :
1. Low Level Languages
2. High Level Languages

Jan 6, 2025 2
Low Level Languages
 Low level languages are used to write programs that relate to
the specific architecture and hardware of a particular type of
computer.
 They are closer to the native language of a computer (binary),
making them harder for programmers to understand.

Examples of low level language:


 Machine language

 Assembly language

Jan 6, 2025 3
Machine language
 Machine language is what the computer can understand but
it is difficult for the programmer to understand.
 A program written in machine language is a collection of
binary digits or bits that the computer reads and interprets.
 It is a system of instructions and data executed directly by a
computer’s CPU.
 It is also referred to as machine code or object code.
 It is written as strings of 0’s and 1’s.

Jan 6, 2025 4
Machine language
Some of the features of machine language are given below :
The computer can understand the programs written in machine

language directly. No translation of the program is needed.


Program written in machine language can be executed very fast

(Since no translation is required).


 It is efficient for the computer but very inefficient for

programmers. It is considered to the first generation language.

Jan 6, 2025 5
Machine language
 Machine language is defined by the hardware of a computer.
It depends on the type of the processor that the computer uses
and is thus machine-dependent. A machine level program
written on one computer may not work on another
computer with a different processor.

 It is difficult to write a program in machine language as it has


to be written in binary code. For e.g., 0001000101110001.
Such programs are also difficult to modify.

Jan 6, 2025 6
Machine language
Advantage of Machine Language:
The only advantage is that program of machine language run
very fast because no translation program is required for the CPU.

Disadvantages of Machine Language:


1. It is very difficult to program in machine language. The
programmer has to know details of hardware to write program.
2. The programmer has to remember a lot of codes to write a
program which results in program errors.
3. It is difficult to debug the program.

Jan 6, 2025 7
Assembly language
 Assembly language was developed to overcome some of the many
inconveniences of machine language.
 It is considered to be a second-generation language. This is
another low level but a very important language in which operation
codes and operands are given in the form of alphanumeric symbols
instead of 0’s and l’s.
 These alphanumeric symbols will be known as mnemonic codes
e.g. ADD for addition, SUB for subtraction etc.
 Because of this feature it is also known as ‘Symbolic Programming
Language’.
 Small, English-like representation is used to write the program in
assembly language.
Jan 6, 2025 8
Assembly language
Some of the features of a program written in assembly language
are as follows:
Assembly language programs are easier to write than the machine

language programs, since assembly language programs use short,


English-like representation of machine code. For e.g.:
ADD 2,3

LOAD A

SUB A,B

The program written in assembly language is the source code,

which has to be converted into machine code, also called object


code, using translator software, namely assembler.
Jan 6, 2025 9
Assembly language
 Each line of the assembly language program is converted into
one or more lines of machine code. Hence assembly language
programs are also machine-dependent.
 Although assembly language programs use symbolic
representation, they are still difficult to write.
 Assembly language programs are generally written where the
efficiency and the speed of program are the critical issues, i.e.
programs requiring high speed and efficiency.

Jan 6, 2025 10
Assembly language
Advantages of Assembly Language:
1.The symbolic programming of Assembly Language is easier to
understand and use as compared to machine language.
2. It is easier to correct errors and modify program instructions
compared to machine language.

Disadvantages of Assembly Language:


1.One of the major disadvantages is that assembly language is
machine-dependent. A program written for one computer might
not run in other computers with different hardware configuration.

Jan 6, 2025 11
HIGH LEVEL LANGUAGES
 High Level Languages are user-friendly languages which are similar to
English with vocabulary of words and symbols. These are easier to learn
and require less time to write.
 Higher level languages are problem-oriented languages because the
instructions are suitable for solving a particular problem.
examples :
 COBOL (Common Business Oriented Language) is mostly suitable
for business oriented language where there is very little processing and
huge output. There are mathematical oriented languages
like FORTRAN (Formula Translation) and BASIC (Beginners All-
purpose Symbolic Instruction Code) where very large processing is
required.
 Python, C , Java
Jan 6, 2025 12
HIGH LEVEL LANGUAGES
 Programs are easier to write, read or understand in high-level
languages than in machine language or assembly language. For
example, a program written in C++ is easier to understand than
machine language program.
 Programs written in high-level languages is the source code which
is converted into the object code using translator software like
interpreter or compiler.
 A line of code in high-level program may correspond to more than
one line of machine code.
 Program written in high-level languages are easily portable from
one computer to another.

Jan 6, 2025 13
HIGH LEVEL LANGUAGES
Advantages of High Level Languages:
 User-friendly

Similar to English with vocabulary of words and symbols


Therefore it is easier to learn.

They require less time to write.

They are easier to maintain.

Problem oriented rather than 'machine' based.

Program written in a high-level language can be translated into many machine

language and therefore can run on any computer for which there exists an appropriate
translator.
It is independent of the machine on which it is used i.e. Programs developed in high

level language can be run on any Computer. (Program written in high-level languages
are easily portable from one computer to another.)

Jan 6, 2025 14
HIGH LEVEL LANGUAGES

Disadvantages of High Level Language:


 A high-level language has to be translated into the machine

language by a translator and thus a price in computer time is


paid.

Jan 6, 2025 15
TRANSLATOR SOFTWARE (PROGRAM
TRANSLATORS)
 A computer can only understand programs defined using machine
code.
 Consequently, a program written in a high level language cannot be
run directly.
 To execute a computer program written in high or low level
language, it must be translated. There are 3 types of system software
used for translating the code that a programmer writes into a form
that the computer can execute (i.e. machine code). These are:
 1. Assembler
 2. Compiler
 3. Interpreter

Jan 6, 2025 16
TRANSLATOR SOFTWARE

Source Code Compiler Object Code


Assembler
Interpreter

Jan 6, 2025 17
TRANSLATOR SOFTWARE
 A program written in a particular programming language is
known as source code.
 To execute the program, it must be translated into machine
language, ie the language that the computer understands.
The translated program is called the object code.
 Assembler converts a program written in assembly
language to machine language.
 Compiler and interpreter convert a program written in
high-level language to machine language.

Jan 6, 2025 18
1.Assembler
 Assembly language is also referred to as a symbolic
representation of the machine code.

 Assembler is a software that converts a program written in


assembly language into machine code.

 There is usually a one-to-one correspondence between


simple assembly statements and machine language
instructions.

Jan 6, 2025 19
1.Assembler
Advantages of using an Assembler:
Very fast in translating assembly language to machine code as 1 to 1

relationship
Assembly code is often very efficient (and therefore fast) because it is a low

level language
Assembly code is fairly easy to understand due to the use of English-like

mnemonics
Disadvantages of using Assembler:
Assembly language is written for a certain instruction set and/or processor
Assembly tends to be optimised for the hardware it's designed for, meaning it is often

incompatible with different hardware


 Lots of assembly code is needed to do relatively simple tasks, and complex programs

require lots of programming time.


2.Compiler
2.Compiler

• Each programming language has its own compiler.


• Some languages that use a compiler are C, C++, COBOL, Pascal
and FORTRAN.
• In some languages, compilation using the compiler and linking
using the linker are required for creating the executable object code.
• The compilation process generally involves two parts – breaking
down the source code into small pieces and creating an intermediate
representation, and constructing the object code for the intermediate
representation.
• The compiler also reports syntax errors in the source code.
3. Interpreter

• The purpose of interpreter is similar to that of a compiler.


• The interpreter is used to convert the high-level language program
into computer-understandable form.
• However, the interpreter functions in a different way than a
compiler.
• Interpreter performs line-by-line execution of the source code
during program execution.
• Interpreter reads the source code line-by-line, converts it into
machine understandable form, executes the line and then proceeds
to the next line.
• Some languages that use an interpreter are BASIC and Python.
Compiler Interpreter

1 Compiler looks at the entire source code. Interpreter looks at a source code
line-by-line.

2 Intermediate Object Code is Generated No Intermediate Object Code is Generated

3 Program need not be compiled every time Every time higher level program is
converted into lower level program

4 During execution of an object code, the For interpretation, both interpreter and the
compiler is not required. source code is required during execution.

5 It takes large amount of time to analyze the It takes less amount of time to analyze the
source code but the overall execution time source code but the overall execution time
is comparatively faster. is slower.

6 Errors are displayed after entire Errors are displayed for every
program is checked instruction interpreted (if any)

7 Programming language like C, C++ use Programming language like Python, use
compilers. interpreters.

You might also like