What type of translator is used for python?

Home » Compiler » What is Translators? Different type of translators

A program written in high-level language is called as source code. To convert the source code into machine code, translators are needed.

A translator takes a program written in source language as input and converts it into a program in target language as output.

It also detects and reports the error during translation.

Roles of translator are:

• Translating the high-level language program input into an equivalent machine language program.

• Providing diagnostic messages wherever the programmer violates specification of the high-level language program.

The different types of translator are as follows:

Compiler

Compiler is a translator which is used to convert programs in high-level language to low-level language. It translates the entire program and also reports the errors in source program encountered during the translation.

               

Interpreter

Interpreter is a translator which is used to convert programs in high-level language to low-level language. Interpreter translates line by line and reports the error once it encountered during the translation process.

It directly executes the operations specified in the source program when the input is given by the user.

It gives better error diagnostics than a compiler.

               

                                 Differences between compiler and interpreter

SI. No

Compiler

Interpreter

1

Performs the translation of a program as a whole.

Performs statement by statement translation.

2

Execution is faster.

Execution is slower.

3

Requires more memory as linking is needed for the generated intermediate object code.

Memory usage is efficient as no intermediate object code is generated.

4

Debugging is hard as the error messages are generated after scanning the entire program only.

It stops translation when the first error is met. Hence, debugging is easy.

5

Programming languages like C, C++ uses compilers.

Programming languages like Python, BASIC, and Ruby uses interpreters.

Assembler

Assembler is a translator which is used to translate the assembly language code into machine language code.

             

KS3 Translators Resources [14-16 years]

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

A-Level Translators Resources [16-18 years]

  • An editable PowerPoint lesson presentation
  • Editable revision handouts
  • A glossary which covers the key terminologies of the module
  • Topic mindmaps for visualising the key concepts
  • Printable flashcards to help students engage active recall and confidence-based repetition
  • A quiz with accompanying answer key to test knowledge and understanding of the module

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.

Purpose of Translator

It translates a high-level language program into a machine language program that the central processing unit [CPU] can understand.  It also detects errors in the program.

Different Types of Translators

There are 3 different types of translators as follows:

Compiler

A 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.  The 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, the 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

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 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:

TranslatorExamples
Compiler Microsoft Visual Studio
GNU Compiler Collection [GCC]
Common Business Oriented Language [COBOL]
Interpreter OCaml
List Processing [LISP]
Python
Assembler Fortran Assembly Program [FAP]
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:

  • 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.

Further Readings:

  • Translator [computing]

What is the translator used in Python?

Python googletrans is a module to translate text. It uses the Google Translate Ajax API to detect langauges and translate text.

What type of interpreter does Python use?

The Python interpreter is a bytecode interpreter: its input is instruction sets called bytecode. When you write Python, the lexer, parser, and compiler generate code objects for the interpreter to operate on.

What are the 3 types of translators?

Generally, there are three types of translator: compilers. interpreters. assemblers.

Which interpreter is good for Python?

CPython provides the highest level of compatibility with Python packages and C extension modules. If you are writing open source Python code and want to reach the widest possible audience, targeting CPython is best. To use packages which rely on C extensions to function, CPython is your only implementation option.

Chủ Đề