Introduction to Programming
Languages
Programming Languages
■ Language is a means of communication.
■ Programming languages are used to write a program, which
controls the behavior of computers, codify the algorithms
precisely, or enables the human-computer interface.
■ Each language has a unique set of keywords and a special
syntax for organizing program instructions.
⚫ Through a language the computer user can state what
commands the computer should carry out to process the data.
⚫ The programming language should be understood, both by
the programmer and the computer.
⚫ A computer understands the language of 0’s and 1’s , while
the programmer is more comfortable with English-like
language.
⚫ Programming Language usually refers to high-level
languages like COBOL, BASIC, FORTRAN, C, C++, Java
etc.
Classification of Computer Languages
Machine Language
⚫ Language directly understood by a computer.
⚫ No translation of the program is needed.
⚫ Program written in machine language can be executed very
fast (Since no translation is required).
⚫ Each kind of CPU has its own unique machine language.
⚫ It is also referred to as machine code or object code.
⚫ It is written as strings of binary 0s and 1s.
⚫ For eg: 101101010 has a specific meaning for a computer
Machine Language
■ Instruction Format:
■ OPCODE tells the computer which operation to perform
from the instruction set of the computer.
■ OPERAND tells the address of the data on which the
operation is to be performed.
Machine Language
■ Advantages:
■ Can be executed very fast
■ Suited for small computers having limited memory.
■ Disadvantages:
■ Machine dependent
■ Difficult to program
■ Error prone
■ Difficult to modify.
Assembly Language
⚫ Programming language that overcomes the limitations of
machine level language.
⚫ Assembly Language falls in between machine language and
high-level language.
⚫ 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.
⚫ Uses Mnemonic Operation Codes and Symbolic Addresses.
■ An instruction consists of three parts:
■ A label - symbolic address of the instruction
■ An operation code - operation to be performed
■ An operand - symbolic address of memory
■ Format:
■ LABEL: OPERATION CODE OPERAND
■ Eg:- ADD A, B ; Adds the values at the operands
addressed by A and B, result at A
Assembly Language
■ Advantages:
■ Easy to understand
■ Easy to locate and correct errors
■ Easy to modify
■ Efficiency almost same as machine language
■ Disadvantages:
■ Machine dependent
■ An intermediate translating program is required
■ Cannot be executed in small sized computers
■ Knowledge of hardware required.
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.
⚫ Machine independent
⚫ Knowledge about the internal structure of the computer is
not necessary
High Level Languages
■ Advantages:
■ Machine independent
■ Easy to learn and use
■ Less errors during program development
■ Easy to modify and maintain
■ Disadvantages:
■ Takes more time to run and require more storage
Machine language and assembly languages are also called
low-level languages, and are generally used to write the
system software.
Application software is usually written in high-level
languages. The program written in a programming language is
also called the source code.
Regardless of the programming language used, the
program needs to be converted into machine
language so that the computer can understand it. In
order to do this a program is either compiled or
interpreted.
TRANSLATOR SOFTWARE
(PROGRAM TRANSLATORS)
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
⚫ 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.
Assembler
■ Assembler is a software that translates assembly
language program into machine language program
Compiler
⚫ Compiler is the software that translates the program
written in a high-level language to machine
language.
⚫ Every language (eg: Python, C, C++, JAVA, etc)
has its own compiler
⚫ The compiler also reports syntax errors in the
source code.
Compiler
Interpreter
⚫ The purpose of interpreter is similar to that of a compiler. The
interpreter is used to convert the high-level language into
machine language.
⚫ 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.
Interpreter
DIFFERENCE BETWEEN A
COMPILER AND AN INTERPRETER
Compiler and Interpreter are used to convert a program
written in high-level language to machine language;
however, they work differently.
The key differences between a compiler and an interpreter
are as follows :
Software Classification
System Software
■ For doing system related tasks.
■ Eg: Operating Systems, Compilers, interpreters, Device
Drivers
Application Software
■ For doing a specific user task.
■ Eg: MS Office, Photoshop, MS Paint, etc..
Types of Softwares