Computer Language Translator and its Types

A translator is a computer program that translates a program written in a given programming language into a functionally equivalent program in a different language.

Depending on the translator, this may mean changing or simplifying the flow of the program without changing its core. This makes a program that works the same as the original.

Types of Language Translators

There are mainly three types of translators that are used to translate different programming languages into machine-equivalent code:

  1. Assembler
  2. Compiler
  3. Interpreter

Assembler

An assembler translates assembly language into machine code.

Assembly language consists of mnemonics for machine op-codes, so assemblers perform a 1:1 translation from mnemonic to direct instruction. For example, LDA #4 converts to 0001001000100100.

Conversely, one instruction in a high-level language will translate to one or more instructions at the machine level.

The Benefits of Using Assembler

Here is a list of the advantages of using assembler:

  • As a 1 to 1 relationship, assembly language to machine code translation is very fast.
  • Assembly code is often very efficient (and therefore fast) because it is a low-level language.
  • Assembly code is fairly easy to understand due to the use of English, like in mnemonics.

The Drawbacks of Using Assembler

Assembly language is written for a certain instruction set and/or processor.

Assembly tends to be optimized for the hardware it is designed for, meaning it is often incompatible with different hardware.

Lots of assembly code is needed to do a relatively simple task, and complex programs require lots of programming time.

Compiler

A compiler is a computer program that translates code written in a high-level language into a low-level language, machine code.

The most common reason for translating source code is to create an executable program (converting from high-level language into machine language).

Advantages of using a compiler

Below is a list of the advantages of using a compiler:

  • Source code is not included; therefore, compiled code is more secure than interpreted code.
  • tends to produce faster code and is better at interpreting source code.
  • Because the program generates an executable file, it can be run without the need for the source code.

Disadvantages of using a compiler

Below is a list of the disadvantages of using a compiler:

  • Before a final executable file can be created, object code must be generated; this can be a time-consuming process.
  • The source code must be 100% correct for the executable file to be produced.

Interpreter

An interpreter program executes other programs directly, running through the program code and executing it line-by-line. As it analyses every line, an interpreter is slower than running compiled code, but it can take less time to interpret program code than to compile and then run it. This is very useful when prototyping and testing code.

Interpreters are written for multiple platforms; this means code written once can be immediately run on different systems without having to recompile for each. Examples of this include flash-based web programs that will run on your PC, Mac, gaming console, and mobile phone.

Advantages of using an interpreter

Here is a list of some of the main advantages of using an interpreter:

  • easier to debug (check errors) than a compiler.
  • It is easier to create multi-platform code, as each different platform would have an interpreter to run the same code.
  • useful for prototyping software and testing basic program logic.

Disadvantages of using an interpreter

And here is the list of some of the main disadvantages of using an interpreter:

  • Source code is required for the program to be executed, and this source code can be read, making it insecure.
  • Due to the on-line translation method, interpreters are generally slower than compiled programs.

Computer Fundamentals Quiz


« Previous Tutorial Next Tutorial »


Follow/Like Us on Facebook


Subscribe Us on YouTube