Make your own free website on Tripod.com
Computer Appreciation

1.15  Translator :

a) Interpreter:- A program which executes other programs. This is in contrast to a compiler, which does not execute its input program (the "source code") but translates it into executable "machine code" (also called "object code") which is output to a file for later execution. It may be possible to execute the same source code either directly by an interpreter or by compiling it and then executing the machine code produced.

It takes longer to run a program under an interpreter than to run the compiled code but it can take less time to interpret it than the total required to compile and run it. This is especially important when prototyping and testing code when an edit-interpret-debug cycle can often be much shorter than an edit-compile-run-debug cycle.

Interpreting code is slower than running the compiled code because the interpreter must analyze each statement in the program each time it is executed and then perform the desired action whereas the compiled code just performs the action. This run-time analysis is known as "interpretive overhead". Access to variables is also slower in an interpreter because the mapping of identifiers to storage locations must be done repeatedly at run-time rather than at compile time.

There are various compromises between the development speed when using an interpreter and the execution speed when using a compiler. Some systems allow interpreted and compiled code to call each other and to share variables. This means that once a routine has been tested and debugged under the interpreter it can be compiled and thus benefit from faster execution while other routines are being developed. Many interpreters do not execute the source code as it stands but convert it into some more compact internal form. For example, some Basic interpreters replace keywords with single byte tokens, which can be used to index into a jump table. An interpreter might well use the same lexical analyzer and parser as the compiler and then interpret the resulting abstract syntax tree.

There is thus a spectrum of possibilities between interpreting and compiling, depending on the amount of analysis performed before the program is executed. For example Emacs Lisp is compiled to "byte-code" which is a highly compressed and optimized representation of the Lisp source but is not machine code (and therefore not tied to any particular hardware). This "compiled" code is then executed (interpreted) by a byte code interpreter (itself written in C). The compiled code in this case is machine code for a virtual machine, which is implemented not in hardware but in the byte-code interpreter.  

b) Compilers:- A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses. Typically, a programmer writes language statements in a language such as Pascal or C one line at a time using an editor. The file that is created contains what are called the source statements. The programmer then runs the appropriate language compiler, specifying the name of the file that contains the source statements.

When executing (running), the compiler first parses (or analyzes) all of the language statements syntactically one after the other and then, in one or more successive stages or "passes", builds the output code, making sure that statements that refer to other statements are referred to correctly in the final code. Traditionally, the output of the compilation has been called object code or sometimes an object module. (Note that the term "object" here is not related to object-oriented programming.) The object code is machine code that the processor can process or "execute" one instruction at a time.

More recently, the Java programming language, a language used in object-oriented programming, has introduced the possibility of compiling output (called bytecode) that can run on any computer system platform for which a Java virtual machine or bytecode interpreter is provided to convert the bytecode into instructions that can be executed by the actual hardware processor. Using this virtual machine, the bytecode can optionally be recompiled at the execution platform by a just-in-time compiler.

Traditionally in some operating systems, an additional step was required after compilation - that of resolving the relative location of instructions and data when more than one object module was to be run at the same time and they cross-referred to each other's instruction sequences or data. This process was sometimes called linkage editing and the output known as a load module. A compiler works with what are sometimes called 3GL and higher-level languages . An assembler works on programs written using a processor's assembler language. 

 

c) Assemblers:- An assembler is a program that takes basic computer instruction and converts them into a pattern of binary digit that the computer's processor can use to perform its basic operations. Some people call these instructions assembler language and others use the term assembly language.

Here's how it works:

  • Most computers come with a specified set of very basic instructions that correspond to the basic machine operations that the computer can perform. For example, a "Load" instruction causes the processor to move a string of bits from a location in the processor's memory to a special holding place called a register. Assuming the processor has at least eight registers, each numbered, the following instruction would move the value (string of bits of a certain length) at memory location 3000 into the holding place called register 8:
               L        8,3000
  • The programmer can write a program using a sequence of these assembler instructions.
  • This sequence of assembler instructions, known as the source code or source program, is then specified to the assembler program when that program is started.
  • The assembler program takes each program statement in the source program and generates a corresponding bit stream or pattern (a series of 0's and 1's of a given length).
  • The output of the assembler program is called the source code or object program relative to the input source program. The sequence of 0's and 1's that constitute the object program is sometimes called machine code.
  • The object program can then be run (or executable) whenever desired.

In the earliest computers, programmers actually wrote programs in machine code, but assembler languages or instruction sets were soon developed to speed up programming. Today, assembler programming is used only where very efficient control over processor operations is needed. It requires knowledge of a particular computer's instruction set, however. Historically, most programs have been written in "higher-level" languages such as COBOL, FORTRAN, PL/I, and C. These languages are easier to learn and faster to write programs with than assembler language. The program that processes the source code written in these languages is called a compiler. Like the assembler, a compiler takes higher-level language statements and reduces them to machine code.

A newer idea in program preparation and portability is the concept of a . For example, using the Java programming language, the output, called bytecode, is compiled for a theoretical computer. The byte code can then be sent to any computer platform that has previously downloaded or built in the Java virtual machine. The virtual machine is aware of the specific instruction lengths and other particularities of the platform and can execute the Java byte code.


Copyright 2001 Selfonline-Education. All rights reserved.