A programming languages can be defined as a language used for expressing a set of computer instructions (program). It consists of a set of rules that tells the computer what operation to do. These languages are used by the programmers to create other kinds of software.These languages have one thing in common , these must be reduce to digital form 0 or 1 , because that is all a computer can work with.
The programming languages can be divided into two major categories : low level and high level languages. The low level languages can be further divided into machine language and assembly language.The high level languages on the other hand , can be categorized in variety of ways. In one sense, the high level languages can be divided into Problem Oriented and Procedure Oriented languages.
LOW LEVEL LANGUAGES:-
The Low Level Languages are the languages which are easily understood by machines.For example , machine language is a low level language.They are machine dependent languages.That is, these languages are specific to computers.Programs written in these languages are not transferable from one computer to another.
MACHINE LANGUAGES:-
Machine language is the basic language of the computer , representing data as 1 or 0.Any sequence of 0 and 1 forms an instruction in the language.An instruction written in this language is simply a string of binary digits.These binary digits , correspond to the on and off electrical states of the computer.
For example,
1010101011
1110001010 etc.
Each instruction has a specific format , consisting of two fields.The first field is opcode and the second field is address.
Opcode:- (Operation Code) It indicates what operation is to be done.Such as addition, subtraction, multiplication etc.
Address:-It represents the memory location where in the data is referenced.
Length of each instruction is 12 bits , 4 bits for opcode and 8 bits for address.
Advantages:-
- No translator program is required.
- Can be directly typed and executed.
- Programs written in machine languages takes shorter time for execution than a program written in other languages.
Disadvantages:-
- Machine languages is machine dependent and therefore program that runs on one machine does not run on the other.
- All instruction are to be written in binary language which is difficult to remember and leads to errors.
3.Programming in a machine language can be time consuming as it is difficult to debug errors.
ASSEMBLY LANGUAGES:-
Assembly languages uses symbolic names instead of binary numbers.Symbolic word used in this language are referred to as mnemonics.Assembly language program is given as an input to the assembler and the equivalent machine code is generated.
For example
ADD for addition
SUB for subtraction
JMP for jump
Advantages:-
- Operation Codes used in machine languages can be replaced by mnemonics which are easier to remember.
- It is not required to keep the track of memory locations.The memory location are replaced by the variable names.
- Easy to write programs , modify and debug as compared to machine language.
Disadvantages:-
- The mnemonics are machine dependent.They differ from one computer to another.
- Assembly languages is less efficient than machine languages.
LANGUAGE TRANSLATORS:-
A language translator or a language processor is a program which converts statements written in one language into another language.
There are three basic types of translator:-
- Compiler
- Interpreter
- Assembler
Main functions of language translators are :-
- Language translators perform the translation of high level or assembly language into machine language.
- They check for and identify syntax errors that may be present in the program being translated.
COMPILER:-
AS the computer only understand the machine languages, so program written in the high level languages needs to be translated into machine languages before it can be executed by the computer. The compiler translates the source program written in high level language into object program or machine level program.Compilers are large programs which resides permanently on secondly storage.When a program is to be compiled the compiler is copied into the main memory of the computer and is executed in the C.P.U.Besides translating the instructions in high level language into machine language instructions, the compiler also brings out any errors related to the syntax of the specified high level language.
Every language has it’s own compiler and it can translate only those programs which are written in that particular language.
The compiler can diagnose following kinds of errors:-
- Illegal character.
- Illegal combination of characters
- Illegal sequencing of instructions in a program.
INTERPRETER:-
An interpreter is a translating program for the purpose of converting high level language into machine language , however it translates only one statement of a high level language at a time.After translating the statement is immediately executed.This is in contrast to a compiler which translates the entire program into source program.This object code is saved permanently for future use and is used every time the program is to be executed.
However, in the case of an interpreter the object program is not stored because the translation and execution take place alternately.So, if the statement is to be used then it must be interpreted again.
ASSEMBLER:-
A program which translates on assembly language program into machine language program is called assembler.An assembly language program i.e the source program is fed to the computer through an input device.The assembler program present in the computer memory translates this source program into an equivalent machine language program called the object program.
An assembler performs the following functions:-
- Translates symbolic operation codes , and symbolic addresses into actual machine addresses.
- Includes the necessary linkage for closed sub-routines.
- Allocates areas of main memory.
- Will indicate invalid source language instruction.