Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Translators Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

A translator is a computer program that performs the translation of a program written in a given

programming language into a functionally equivalent program in a different computer language, without
losing the functional or logical structure of the original code (the "essence" of each program).

Source code and object code refer to the "before" and "after" versions of a computer program that is
compiled (see compiler) before it is ready to run in a computer.

The source code consists of the programming statements that are created by a programmer with a text
editor or a visual programming tool and then saved in a file.

For example, a programmer using the C language types in a desired sequence of C language statements
using a text editor and then saves them as a named file. This file is said to contain the source code. It is
now ready to be compiled with a C compiler and the resulting output, the compiled file, is often referred
to as object code. The object code file contains a sequence of instructions that the processor can
understand but that is difficult for a human to read or modify. For this reason and because even
debugged programs often need some later enhancement, the source code is the most permanent form
of the program.

Fundamentals of Computer Systems: Types of program


translator
Assembler

An assembler translates assembly language into machine code. Assembly language consists of
mnemonics for machine opcodes so assemblers perform a 1:1 translation from mnemonic to a
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
machine level.

Advantages of using an Assembler:

Very fast in translating assembly language to machine code as 1 to 1 relationship

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 mnem onics

Disadvantages of using Assembler:


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

Assembly tends to be optimised for the hardware it's designed for, meaning it is often incompatible with
different hardware

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

Compiler

A Compiler is a computer program that translates code written in a high level language to a lower level
language, object/machine code. The most common reason for translating source code is to create an
executable program (converting from a high level language into machine language).

Advantages of using a compiler

Tends to produce faster code than interpreting source code

Produces an executable file, and therefore the program can be run without need of the source code

Disadvantages of using a compiler

Object code needs to be produced before a final executable file, this can be a slow 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 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 run immediately on different systems without having to recompile for each. Examples of
this include flash based web programs that will run on your PC, MAC, games console and Mobile phone.

Advantages of using an Interpreter

Easier to debug(check errors) than a compiler

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

Source code is required for the program to be executed, and this source code can be read making it
insecure

Interpreters are generally slower than compiled programs due to the per-line translation method

You might also like