Compiler vs Interpreter

Posted on 2006-04-09
Last Modified: 2013-11-23
Hi, I understand that JVM comes with interpreter and advanced version comes with compiler. I need a clear cut difference between the functionalities of both ( compiler and Interpreter). If older version uses interpreter, what is the need to move on to JVM with Compilers. Which is advantageous, why?..what are the operations of both?.

Question by:nmretd
    LVL 14

    Expert Comment

    There are two main Java releases:
      Java Runtime Environment - allows running java applications and applets.
      Java Development Kit - allows compiling Java source code to bytecode. Also includes JRE.
    LVL 14

    Assisted Solution

    by:Tommy Braas
    Like StillUnAware lists, there are two different distributions available for JVMs. One that is purely a runtime environment (JRE), and one which includes developer tools (the JDK).

    However, that has nothing to do with your question.

    A JVM will execute byte code (which has previously been compiled by a Java compiler) in one of two mode: interpreted or compiled.

    Interpreted mode is when the JVM executes the java byte code as java byte code.
    Compiled mode is when the JVM has compiled the java byte code to native code such that execution of that code will be at, or near, native code speed.

    The main difference between the two is obviously speed. A second difference, which is of importance for developers, is that when the code is interpreted line numbers are preserved and debugging is fairly straight forward. This is not the case for compiled mode. In compiled mode the line numbers are stripped, and this makes it harder to debug.

    Expert Comment



      In java languge when you write code  .all the code is in java .becos java is a platform independent language all your code need to be compiled  .Complier which comes with Java development kit  JDK compiles the java code in to classes .
     JVM is the run time envirnoment for java applications which should be there on every machine you want to run java application.Jvm converts the  java classes in to the machine language .

    LVL 24

    Accepted Solution

    As I don't understand the answers given above I'll give my version:

    The present JAVA (1.5.0_06) comes in ONE version that has an interpreter
    to execute .class files and .jar files and an inbuilt HOTSPOT compiler
    to re-compile critical code into machine language.
    It is very hard to find out when the second comes into action,
    but comparison with ultra-fast C-programs proves that the speed
    of java programs is only a fraction slower, so it works!

    The difference between the JRE (runtime version) and the JDK (development version)
    is only the added source compiler, sources and some tools.

    So, why the compiler? To build programs.
    Why the interpreter? To run programs.
    Why the hotspot compiler? To speed programs up.

    LVL 14

    Expert Comment

    by:Tommy Braas
    >> So, why the compiler? To build programs.
    Assuming you mean the javac compiler, for the same reasons that you compile regular source code files. To transform the textual representation of a program into a form that the machine can understand. The JVM is a Virtual Machine.

    >> Why the interpreter? To run programs.

    >> Why the hotspot compiler? To speed programs up.
    LVL 14

    Expert Comment

    by:Tommy Braas
    Btw, I think our answers deserve more than a grade B.
    LVL 24

    Expert Comment

    orangehead911, read at Matthew 20:1-16 .....................


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    The viewer will learn how to implement Singleton Design Pattern in Java.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now