0.2
– Why translator
The native language of computer is the machine language.
Programs written in any high level language must be translated into a form that
can understand by computer. It can be done by using a piece of software called
translator. There are two different types of translators used to translate the
high level program (source code) into native executable (computer
understandable) code. that are compiler and interpreter.
Compiler:
It is a piece of software developed in either assembly language
or C language. It reads the code from the program written in high level
language (source code) and translates directly into the executable code that
the computer can directly understand. Here the executable code generated by the
compiler can be considered as software. We no more require either the source
code or compiler once the executable code is generated. The executable code
generated by the compiler can be copied on to any other computer and can
be used as software.
Interpreter:
It is a simple program that reads the source code written in
high level language statement by statement and translates into native
executable code. The executable code produced by the interpreter is executed as
it is generated. Interpreter accepts the input either from the user or from
other source while interpreting the program. Need both the interpreter and the
source code every time we execute the program.
Most of the high level languages like Pascal, FORTRAN, C
and C++ use compilers to change the source code into native executable code.
Most of the scripting languages like Perl, JavaScript and VBScript use
interpreters.
Portability:
Portability is the ability of using the same code for different
CPU’s belongs to different architecture.
Both machine and assembly languages are not portable because
instructions differ for different CPU’s. For example, MIPS architecture needs
32bit instruction. Where as x86 architecture, needs variable length
instruction.
C is a portable language because the same code with no or little
change can be used for different CPU’s of different architecture.
Platform dependency:
Combination of operating system and architecture that forms an
environment to execute a program is generally termed as platform. It is known
as different platforms if there is a difference in either architecture or
operating system.
The compiler translates the source code into native executable
code according to the local platform. Executable code generated for one
platform may not work on another platform. For example executable code
generated on windows will not work on Linux system, executable code generated
on Intel architecture may not work on Macintosh PowerPC.
If UNIX wants to work on different architectures then, it must
be compiled on different platforms.
Most of the high level languages like Pascal, FORTRAN, COBOL, C
and C++ are platform dependents. While developing software using these
languages, source must be compiled on different platforms to make different
builds.
The bellow picture is a
snap shot from eclipse official site (www.eclipse.org).
It provides different builds for different operating systems (Windows, Linux,
and Mac OSX) and different architectures (32bit and 64bit).
0 comments:
Post a Comment