Can someome explain to me what this means?

Discussion in 'Computer Science & Culture' started by pluto2, Aug 22, 2008.

Thread Status:
Not open for further replies.
  1. pluto2 Banned Valued Senior Member

    Messages:
    1,085
    In wikipedia it's written that an interpreter may be a program that explicitly executes stored precompiled code made by a compiler which is part of the interpreter system. What does it mean? If the code is precompiled how can it be made by a compiler?
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Enmos Valued Senior Member

    Messages:
    43,184
    It is precompiled because it is first compiled by a compiler ?
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. pluto2 Banned Valued Senior Member

    Messages:
    1,085
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Enmos Valued Senior Member

    Messages:
    43,184
    It's just a clumsy sentence.

    1. Compiler compiles program.
    2. Interpreter executes precompiled program.
     
  8. pluto2 Banned Valued Senior Member

    Messages:
    1,085
    But if the program is precompiled, how can it be made by a compiler? Or maybe it is meant that the program is first compiled by the compiler which is part of the interpreter system and then executed by an interpreter?
     
  9. phlogistician Banned Banned

    Messages:
    10,342
    An interpreted language is not compiled. Take BASIC, you write out your code, and when you run it, the interpreter converts it command by command into machine code, which is executed. The interpreter has chunks of precompiled instructions that correlate to each basic command.
     
  10. pluto2 Banned Valued Senior Member

    Messages:
    1,085
    But what about languages like Java and UCSD Pascal? Are they both compiled and interpreted? And what is machine independent code?
     
  11. Xelios We're setting you adrift idiot Registered Senior Member

    Messages:
    2,447
    Java is not an interpreted language. Python is an example of an interpreted language. You feed the Python interpreter some code, it compiles and executes it in real time. Like you could open up the Python interpreter and give it a single line of code, like display a string, and it'll do it.

    In a language that executes previously compiled code (like Java or C++) you always compile it specifically for one type of machine architecture, if the end user's architecture is different the program won't run. With an interpreted language machine architecture doesn't matter, because the interpreter is fed source code and compiles/runs it when the program is executed. So the interpreter will always compile it to run on whatever architecture it's running on. That's why it's machine independent code.
     
  12. RubiksMaster Real eyes realize real lies Registered Senior Member

    Messages:
    1,646
    It's referring to languages like java.

    1. The java compiler compiles the program into java bytecode (not an executable).

    2. The Java Virtual Machine interprets the bytecode. Each OS has a different way of interpreting the bytecode.

    The key phrase is this: "made by a compiler which is part of the interpreter system." Meaning the interpreter compiles the code into a form that the interpreter can execute.
     
  13. Stryder Keeper of "good" ideas. Valued Senior Member

    Messages:
    13,105
    They really should of just stated "Interpreters Interpret, Compilers Compile".

    Commonly interpreted languages are things like VBscript, PHP, Perl, Javascript. Although Perl can be "Compiled" into an executable version that then allows a standalone instance to run that doesn't need the entire language to be with it. (I believe Python can do the same in this instance)

    The many instances of "C" require Compiling before they can run for the most part, unless the programming environment being used allows it to be "Interpreted" for testing. (The same goes for Java, Visual Basic, Pascal etc)
     
  14. Crunchy Cat F-in' *meow* baby!!! Valued Senior Member

    Messages:
    8,423
    I think I understand what they mean, but the wording of it just ain't that good. An interpreter traditionally:

    1) Takes a line of human-readable code.
    2) Parses it for information.
    3) Uses that information to look up a "known" action that the computer understands.
    4) Executes the action.

    Then it's on to the next line. 'Pre-compilation' with an interpreter typically means that steps 1-3 are performed ahead of time for multiple lines of code and stored in a sequential 'action' table.

    The advantage of course is that all those actions can be executed at any moment without having to perform steps 1-3 (which improves performance). Java is an example of an interpreter that works off of 'pre-compilation'. It's 'action' table is called 'byte-code'.
     
Thread Status:
Not open for further replies.

Share This Page