Language Translator
Submitted to: Submitted by:
Miss Sufia Rajput F-16CS31
Content
 Language Translators
 Compiler
 Interpreter
 Assembler
 Why Language Translators?
 Difference between compiler and interpreter
2/13/2018F-16cs31
2
Language Translator
 Language translator is a program that converts the source code
in to the object code.
Converter
Translator
Source Code Translator Object Code
2/13/2018F-16cs31
3
Why Language Translators?
 Computer only understands object code (machine code).
 It does not understand any source code.
 There must be a program that converts source code in to the object code
so that the computer can understand it.
 The language translator is one which does this job.
 The programmer writes the source code and then translator converts it
in machine readable format (object code).
2/13/2018F-16cs31
4
Types of Language Translators
 There are Three types of Language Translator
Assembler
Compiler
Interpreter
2/13/2018F-16cs31
5
Assembler
 Assembler is the language translator that converts assembly
language code in to the object code (machine code).
Convert
Translator
Assembly
Source Code
Assembler Object Code
2/13/2018F-16cs31
6
Compiler
 Compiler is the language translator that converts high level
language code in to the object code (machine code).
 It converts the whole code at a time.
Convert
Translator
High-Level
Source Code
Compiler Object Code
2/13/2018F-16cs31
7
Compiler
Program Read whole program
Line 1 : Instruction 1 Line 1 : Instruction 1 Convert whole program Execute
Line 2 : Instruction 2 Line 2 : Instruction 2 in to object code
Line 3 : Instruction 3 Line 3 : Instruction 3
Line 4 : Instruction 4 Line 4 : Instruction 4
Line 5 : Instruction 5 Line 5 : Instruction 5
1 2 3 4
2/13/2018F-16cs31
8
Interpreter
 Interpreter is the language translator that converts high level
language code in to the object code (machine code).
 It converts the code line by line.
Convert
Translator
High-Level
Source Code
Interpreter Object Code
2/13/2018F-16cs31
9
Interpreter
Program
Line 1 : Instruction 1 Read Line 1 Convert in to Object code Execute 2
Line 2 : Instruction 2 Read Line 2 Convert in to Object code Execute 3
Line 3 : Instruction 3 Read Line 3 Convert in to Object code Execute 4
Line 4 : Instruction 4 Read Line 4 Convert in to Object code Execute 5
Line 5 : Instruction 5 Read Line 5 Convert in to Object code Execute 6
1
2/13/2018F-16cs31
10
Difference between Compiler and Interpreter
Compiler
 It converts whole code at a time.
 It is faster.
 Requires more memory.
 Errors are displayed after entire program
is checked.
 Example: C, C++, JAVA.
Interpreter
 It converts the code line by line.
 It is slower.
 Requires less memory.
 Errors are displayed for every
instruction
interpreted (if any)
 Example: GW BASIC, Ruby, Python
2/13/2018F-16cs31
11
2/13/2018F-16cs31
12

Computer Language Translator

  • 1.
    Language Translator Submitted to:Submitted by: Miss Sufia Rajput F-16CS31
  • 2.
    Content  Language Translators Compiler  Interpreter  Assembler  Why Language Translators?  Difference between compiler and interpreter 2/13/2018F-16cs31 2
  • 3.
    Language Translator  Languagetranslator is a program that converts the source code in to the object code. Converter Translator Source Code Translator Object Code 2/13/2018F-16cs31 3
  • 4.
    Why Language Translators? Computer only understands object code (machine code).  It does not understand any source code.  There must be a program that converts source code in to the object code so that the computer can understand it.  The language translator is one which does this job.  The programmer writes the source code and then translator converts it in machine readable format (object code). 2/13/2018F-16cs31 4
  • 5.
    Types of LanguageTranslators  There are Three types of Language Translator Assembler Compiler Interpreter 2/13/2018F-16cs31 5
  • 6.
    Assembler  Assembler isthe language translator that converts assembly language code in to the object code (machine code). Convert Translator Assembly Source Code Assembler Object Code 2/13/2018F-16cs31 6
  • 7.
    Compiler  Compiler isthe language translator that converts high level language code in to the object code (machine code).  It converts the whole code at a time. Convert Translator High-Level Source Code Compiler Object Code 2/13/2018F-16cs31 7
  • 8.
    Compiler Program Read wholeprogram Line 1 : Instruction 1 Line 1 : Instruction 1 Convert whole program Execute Line 2 : Instruction 2 Line 2 : Instruction 2 in to object code Line 3 : Instruction 3 Line 3 : Instruction 3 Line 4 : Instruction 4 Line 4 : Instruction 4 Line 5 : Instruction 5 Line 5 : Instruction 5 1 2 3 4 2/13/2018F-16cs31 8
  • 9.
    Interpreter  Interpreter isthe language translator that converts high level language code in to the object code (machine code).  It converts the code line by line. Convert Translator High-Level Source Code Interpreter Object Code 2/13/2018F-16cs31 9
  • 10.
    Interpreter Program Line 1 :Instruction 1 Read Line 1 Convert in to Object code Execute 2 Line 2 : Instruction 2 Read Line 2 Convert in to Object code Execute 3 Line 3 : Instruction 3 Read Line 3 Convert in to Object code Execute 4 Line 4 : Instruction 4 Read Line 4 Convert in to Object code Execute 5 Line 5 : Instruction 5 Read Line 5 Convert in to Object code Execute 6 1 2/13/2018F-16cs31 10
  • 11.
    Difference between Compilerand Interpreter Compiler  It converts whole code at a time.  It is faster.  Requires more memory.  Errors are displayed after entire program is checked.  Example: C, C++, JAVA. Interpreter  It converts the code line by line.  It is slower.  Requires less memory.  Errors are displayed for every instruction interpreted (if any)  Example: GW BASIC, Ruby, Python 2/13/2018F-16cs31 11
  • 12.