Tuesday, 26 February 2013

Interpreter vs Compiler

By Raul Bernardino

Introduction:
[1] In the computing field, the commands or instructions which are given by the users are normally use a high level language, whereas the computer machines will only  understand the instructions in the binary formats.  The computer language is known as machine language. The sole purpose of the compiler and interpreter is to convert the user high level language into a machine level language so that it makes the computer understand and executed users’ instructions.

 [2] The translation from high level to a low level machine language calls translator. The translator will be translating all identifier of high level collection into the machine language. The translator act similar to secondary generation of assembler, however, it does not do a compiling.

The assembler uses to compile the machine instructions into short sequence of activities in one single file. The assembler is compiling the instructions, calls compilers.
The other translator calls interpreter. This interpreter is doing an execution of the instructions of the program from high level generation without translating into the machine language.

There would be more delay on interpreting instructions from high level and executing compare to transiting or compiling into low level of programming and execute.

[3] Below diagram shows the compilation and interpretation:


By implementing these two distinctions of the interpreting and compiling, it has its own merits and weakness. If we are using an interpreting mode e.g. the web animation, it will be taking further delay of displaying in other end of the machine. It is because the source codes are in different location. Meanwhile, compiling web animation the source code will be going with the web site, however developer have to think of how it can be display in the far end machine while he or she have no idea what type machine is in the far end. Maybe she or he the developer has some assumption of the type machines. But it is unrealistic. Therefore, more developer are using interpreting mode today.

[4] Why is that most of developer are using interpreter mode in design compare to compiler? There are several reasons as follow:

The Interpreter:
  1. Easier to build an interactive development of the environments
  2. Easy to execute the instructions codes which are they are executed statement by statement
  3. Become a port to different the OSs and processor.
  4. The bytecode is portable to any system with an interpreter port.
  5. Bytecodes are tightly packed   
  6. The only weakness is boring performance
 The compiler:
  1. Compiling whole program in to the machine language
  2. Run in the specific operating system an processor
  3. Machine codes are not dense
  4. Run more faster

References:

[1] What are the differences between Compiler and Interpreter? [Internet]. Available from: http://readanddigest.com/what-are-the-differences-between-compiler-and-interpreter/ (Accessed:  6 November 2010)

[2] J. Glenn Brookshear, (2009) Computer science: An Overview. 10th Edition, Boston: Pearson Addison Wesley, Ch 6, P.282 and P.312

[3] What is the difference between compiler and interpreter? [Internet]. Available from:

http://stackoverflow.com/questions/3618074/what-is-the-difference-between-compiler-and-interpreter (Accessed:  6 November 2010)

[4] The difference between compiler and interpreter [internet].Available from: http://www.antlr.org/wiki/display/ANTLR3/The+difference+between+compilers+and+interpreters (Accessed:  6 November 2010)

 

1 comment:

  1. Moreover, [1], [2] the programming paradigms are approaches of solving programming problems.

    •Imperative or procedural Programming: The imperative or procedural programming has a series of statements and containing of variables and the program execution also involves changing the memory contents of the computer continuously. – E.g. are FOTRAN, C, Pascal, COBOL etc. It also relative low using memory and relative efficient

    • Object-Oriented Programming: is an object mode in which is communicating with each other by sending message. The conceptual is very simple, model of computation is better and increase the productivity

    • Functional Programming: is consist of the function and the uses of the functions in the similarity way as we used in mathematic; small and clean syntax, better support for reasoning about program; its allow function to treated as any other data values, they support programming at the relative high level than the imperative language. The execution involve calling function each other and return the result

    • Logical Programming: it’s consisting of set of predicate and rules of interface; each rule is interfering is statement like Prolog.

    [4] Machine language: is a low level of programming language. This is the only way of the language that machine can understand. It is easy for machine but not easy for human. Machine language using bits or hex code for example ‘1010’ binary code, ‘A’ in Hex code and so on.

    Assembly language: is more human readable. Instead of using numeric the instructions and register are given the name or symbolic or mnemonic code for example ‘MOV’ stand for Move, ‘CLC’ stand Clear Carry, ‘ld’ for Load and so

    a. [5] Operator Precedence: The operations occur in an expression; the parts are evaluating and resolving in predetermine ordered. If expressions contain more than one category, the arithmetic operator is evaluating in a first place, following by comparison operators which are evaluating in the next place, and the logical operators which are evaluating in the very last moment.

    b. The operator precedence value of the 6+2*3 is follows: first calculate 2 multiple 3 and the result adding to the 6 and the last result is 12

    Programming language is strongly typed; why is that? [6] Because strongly-typed may have several meaning is depends on context. Some contains are type of notation which associate with variable names, compile time check, run time check and conversion between different types are forbidden.


    References:
    [1] Overview of the four main programming paradigms [internet]. Available from: http://www.cs.aau.dk/~normark/prog3-03/html/notes/paradigms_themes-paradigm-overview-section.html (Accessed: 10 November 2010)

    [2] Programming Paradigms [internet]. Available from: http://www.cs.aau.dk/~normark/prog3-03/html/notes/paradigms_themes-paradigms.html (Accessed: 10 November 2010)

    [3] Machine language [internet]. Available from: http://www.webopedia.com/TERM/M/machine_language.html (Accessed: 10 November 2010)

    [4] Operator Precedence [internet]. Available from: http://www.csidata.com/custserv/onlinehelp/vbsdocs/vbs232.htm (Accessed: 10 November 2010)

    [5] Strongly-typed programming languages – Definition [internet]. Available from: http://www.wordiq.com/definition/Strongly-typed_programming_languages (Accessed: 10 November 2010)

    ReplyDelete