Prof. R.R.
Ahirwal (SATI, VIDISHA)
Compiler
Language:- Language is a medium of communication or exchanging thoughts between any group. A language is the
main medium of communicating between the Computer systems and the most common are the
programming languages. As we know a Computer only understands binary numbers that is 0 and 1 to
perform various operations but the languages are developed for different types of work on a Computer. A
language consists of all the instructions to make a request to the system for processing a task. From the first
generation and now fourth generation of the Computers there were several programming languages used to
communicate with the Computer.
Here we will go in the detail of the Computer language and its types.
A Computer language includes various languages that are used to communicate with a Computer machine.
Some of the languages like programming language which is a set of codes or instructions used for
communicating the machine. Machine code is also considered as a computer language that can be used for
programming. And also HTML which is a computer language or a markup language but not a
programming language. Similarly there are different types of languages developed for different types of
work to be performed by communicating with the machine. But all the languages that are now available are
categorized into two basic types of languages including
Low-level language and High level language.
Low Level Language:
Low level languages are the machine codes in which the instructions are given in machine language in the
form of 0 and 1 to a Computer system. It is mainly designed to operate and handle all the hardware and
instructions set architecture of a Computer. The main function of the Low level language is to operate,
manage and manipulate the hardware and system components. There are various programs and
applications written in low level languages that are directly executable without any interpretation or
translation.
Low level language is also divided into two parts are Machine language and Assembly language.
Machine Language:-
Machine Language is one of the low-level programming languages which is the first generation language
developed for communicating with a Computer. It is written in machine code which represents 0 and 1
binary digits inside the Computer string which makes it easy to understand and perform the operations. As
we know a Computer system can recognize electric signals so here 0 stands for turning off electric pulse and
1 stands for turning on electric pulse.
The main advantage of using Machine language is that there is no need of a translator or interpreter to
translate the code, as the Computer directly can understand.
It is very easy to understand by the Computer and also increases the processing speed.
Prof. R.R. Ahirwal (SATI, VIDISHA)
But there are some disadvantages also like you have to remember the operation codes, memory address
every time you write a program.
Hard to find errors in a written program.
It is a machine dependent and can be used by a single type of Computer.
Assembly Language:-
Assembly Language is the second generation programming language that has almost similar structure and
set of commands as Machine language. Instead of using numbers like in Machine languages here we use
words or names in English forms and also symbols. The programs that have been written using words,
names and symbols in assembly language are converted to machine language using an Assembler. Because a
Computer only understands machine code languages that’s why we need an Assembler that can convert the
Assembly level language to Machine language so the Computer gets the instruction and responds quickly.
The main disadvantage of this language is that it is written only for a single type of CPU and does not run
on any other CPU. That’s mean it is also machine dependent. Finding error and correcting them in written
program still a problem. It need translator as well. But its speed makes it the most used low level language
till today which is used by many programmers.
High Level Language
The high level languages are the most used and also more considered programming languages that helps a
programmer to read, write and maintain. It is also the third generation language that is used and also
running till now by many programmers. They are less independent to a particular type of Computer and
also require a translator that can convert the high level language to machine language. The translator may
be an interpreter and Compiler that helps to convert into binary code for a Computer to understand. There
is various high level programming languages like C, FORTRAN or Pascal that are less independent and
also enables the programmer to write a program.
There are several high level languages that were used earlier and also now like COBOL, FORTRAN,
BASIC, C, C++, PASCAL, LISP, Ada, Algol, Prolog and Java. It is user-friendly as the programs are
Prof. R.R. Ahirwal (SATI, VIDISHA)
written in English using words, symbols, characters, numbers that needs to be converted to machine code
for processing.
Advantages:-
Prof. R.R. Ahirwal (SATI, VIDISHA)
1. Ease of understanding.
2. Naturalness.
3. Portability.
4. Efficiency of use.
Advantages:-
It needs a translator that takes more time to translate high level programming into machine language.
Difference between Machine language and Assembly Language
Machine Language Assembly Language
Machine language is only understood by the Assembly language is only understood by human
computers. beings not by the computers.
In machine language data only represented with the In assembly language data can be represented with
help of binary format (0s and 1s), hexadecimal and the help of mnemonics such as Mov, Add, Sub,
octadecimal. End etc.
Machine language is very difficult to understand by Assembly language is easy to understand by the
the human beings. human being as compare to machine language.
Modifications and error fixing cannot be done in Modifications and error fixing can be done in
machine language. assembly language.
Machine language is very difficult to memorize so it is Easy to memorize the assembly language because
not possible to learn the machine language. some alphabets and mnemonics are used.
Execution is fast in machine language because all data Execution is slow as compared to machine
is already present in binary format. language.
There is no need of translator. The machine Assembler is used as translator to convert
understandable form is the machine language. mnemonics into machine understandable form.
Assembly language is the machine dependent and
Machine language is hardware dependent.
it is not portable.
Assembly language vs high-level language
1. In assembly language programs written for one processor will not run on another type of processor.
In high-level language programs run independently of processor type.
2. Performance and accuracy of assembly language code are better than a high-level.
Prof. R.R. Ahirwal (SATI, VIDISHA)
3. High-level languages have to give extra instructions to run code on the computer.
4. Code of assembly language is difficult to understand and debug than a high-level.
5. One or two statements of high-level language expand into many assembly language codes.
6. Assembly language can communicate better than a high-level Some type of hardware actions can
only be performed by assembly language.
7. In assembly language, we can directly read pointers at a physical address which is not possible in
high-level
8. Working with bits is easier in assembly language.
9. Assembler is used to translate code in assembly language while the compiler is used to compile code
in the high-level.
10. The executable code of high-level language is larger than assembly language code so it takes a longer
time to execute.
11. Due to long executable code, high-level programs are less efficient than assembly language programs.
12. High-level language programmer does not need to know details about hardware like registers in the
processor as compared to assembly programmers.
13. The most high-level language code is first automatically converted into assembly code.
Translators
A translator is a programming language processor that converts a computer program from one language to
another. It takes a program written in source code and converts it into machine code. It discovers and identifies
the error during translation.
Computers only understand machine code (binary), this is an issue because programmers prefer to use a variety of
high and low-level programming languages instead.
To get around the issue, the high-level and low-level program code (source code) needs to pass through a
translator.
A translator will convert the source code into machine code (object code).
There are several types of translator programs, each able to perform different tasks.
Compiler
Compilers are used to translate a program written in a high-level language into machine code (object code).
Once compiled (all in one go), the translated program file can then be directly used by the computer and is
independently executable.
Prof. R.R. Ahirwal (SATI, VIDISHA)
Compiling may take some time but the translated program can be used again and again without the need for
recompilation.
An error report is often produced after the full program has been translated. Errors in the program code may cause
a computer to crash. These errors can only be fixed by changing the original source code and compiling the
program again.
That means compiler is a translator used to convert high-level programming language to low-level programming
language. It converts the whole program in one session and reports errors detected after the conversion. Compiler
takes time to do its work as it translates high-level code to lower-level code all at once and then saves it to
memory.
A compiler is processor-dependent and platform-dependent. But it has been addressed by a special compiler, a
cross-compiler and a source-to-source compiler. Before choosing a compiler, user has to identify first the
Instruction Set Architecture (ISA), the operating system (OS) and the programming language that will be used to
ensure that it will be compatible.
Interpreter
Interpreter programs are able to read, translate and execute one statement at a time from a high-level language
program.
Now a day’s interpreter again becomes popular with the advent of internet. These days all the browsers like
internet explorer and net-scap have inbuilt interpreters to view and understand the pages at user-end. Advanced
languages like java consist of one interpreter and on complier.
The interpreter stops when a line of code is reached that contains an error.
Interpreters are often used during the development of a program. They make debugging easier as each line of code
is analyzed and checked before execution.
Interpreted programs will launch immediately, but your program may run slower than a complied file.
No executable file is produced. The program is interpreted again from scratch every time you launch it.
Prof. R.R. Ahirwal (SATI, VIDISHA)
Just like a compiler, is a translator used to convert high-level programming language to low-level programming
language. It converts the program one at a time and reports errors detected at once, while doing the conversion.
With this, it is easier to detect errors than in a compiler.
An interpreter is faster than a compiler as it immediately executes the code upon reading the code.
It is often used as a debugging tool for software development as it can execute a single line of code at a time.
An interpreter is also more portable than a compiler as it is not processor-dependent, you can work between
hardware architectures.
Assembler
An assembler is a translator used to translate assembly language to machine language. It is like a compiler
for the assembly language but interactive like an interpreter. Assembly language is difficult to understand
as it is a low-level programming language. An assembler translates a low-level language, an assembly
language to an even lower-level language, which is the machine code. The machine code can be directly
understood by the CPU.
Examples of Translators
Here are some examples of translators per type:
Translator Examples
Microsoft Visual Studio
GNU Compiler Collection (GCC)
Compiler
Common Business Oriented Language
(COBOL)
OCaml
Interpreter List Processing (LISP)
Python
Fortran Assembly Program (FAP)
Assembler Macro Assembly Program (MAP)
Symbolic Optimal Assembly Program (SOAP)
Advantages and Disadvantages of Translators
Here are some advantages of the Compiler:
• The whole program is validated so there are no system errors.
• The executable file is enhanced by the compiler, so it runs faster.
• User do not have to run the program on the same machine it was created.
Here are some disadvantages of the Compiler:
Prof. R.R. Ahirwal (SATI, VIDISHA)
• It is slow to execute as you have to finish the whole program.
• It is not easy to debug as errors are shown at the end of the execution.
• Hardware specific, it works on specific machine language and architecture.
Here are some advantages of the Interpreter:
• You discover errors before you complete the program, so you learn from your mistakes.
• Program can be run before it is completed so you get partial results immediately.
• You can work on small parts of the program and link them later into a whole program.
Here are some disadvantages of the Interpreter:
• There’s a possibility of syntax errors on unverified scripts.
• Program is not enhanced and may encounter data errors.
• It may be slow because of the interpretation in every execution.
Here are some advantages of the Assembler:
• The symbolic programming is easier to understand thus time-saving for the programmer.
• It is easier to fix errors and alter program instructions.
• Efficiency in execution just like machine level language.
Here are some disadvantages of the Assembler:
• It is machine dependent, cannot be used in other architecture.
• A small change in design can invalidate the whole program.
• It is difficult to maintain.
Summary of translators
Compiler Interpreter Assembler
Translates low-level
Translates high-level languages Temporarily executes high-level
assembly code into machine
into machine code languages, one statement at a time
code
An executable file of
An executable file of machine No executable file of machine
machine code is produced
code is produced (object code) code is produced (no object code)
(object code)
Compiled programs no longer Interpreted programs cannot be Assembled programs no
need the compiler used without the interpreter longer need the assembler
Error report produced once One low-level language
Error message produced
entire program is compiled. statement is usually
immediately (and program stops
These errors may cause your translated into one machine
at that point)
program to crash code instruction
Interpreted code is run through
Compiling may be slow, but the
the interpreter (IDE), so it may be
resulting program code will run
slow, e.g. to execute program
Prof. R.R. Ahirwal (SATI, VIDISHA)
quick (directly on the processor) loops
One high-level language
statement may be several lines
of machine code when compiled
Question-1: What is computer language? Compare High level, Assembly and Machine language.
Question-2: What is a translator? What are different types of translator? Explain.
Question-3: Compare different translator compiler, interpreter and assembler.
Question-4: Write advantages and disadvantages of different types of translator.