aspose file tools*
The moose likes Beginning Java and the fly likes compilation vs interpretation? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compilation vs interpretation?" Watch "compilation vs interpretation?" New topic
Author

compilation vs interpretation?

pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
what is the basic diffrence between compilation and interpretation?


does both things happen in java and C++?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

Since this is a learning site, what do YOU think are the differences betweent the two terms?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
interpretor shows errors in each line is it?

interpretor is available in java only if we use IDE's is it?


compilation means changing the source code to .exe file in C/C++ and in java to bytecode(.class) so that jvm can run it is it right?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
interpretor shows errors in each line is it?

No, that's possible with compiled code as well.

interpretor is available in java only if we use IDE's is it?

No, the Java Runtime Environment (JRE) has both compiling and interpreting modes. Both are available either if the program is run inside of an IDE, or started from the command line.

compilation means changing the source code to .exe file in C/C++ and in java to bytecode(.class) so that jvm can run it is it right?

With Java the source first gets compiled into bytecode in class files. Then at runtime the bytecode is interpreted, and may optionally be compiled to native machine code. When I say "optionally", what that means is that almost always it will get compiled. Using only interpretation makes for much slower programs.
[ November 13, 2007: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
chaithra rao
Greenhorn

Joined: Jun 23, 2009
Posts: 1
Java uses a combination of compilation and interpretation. When you create and save a Java source code file (the file that contains your Java instructions and is saved using the .java extension) it needs to be translated before a computer can understand the instructions. So we compile the .java file. However, unlike other compiled languages, the Java compiler does not produce machine code designed specifically for a particular type of computer. Instead, it produces a new file containing bytecode, and this file has the .class extension. Bytecode is like an idealised form of machine language, and the really special thing about bytecode is that it is not machine dependent. Another words, the bytecode produced by the Java compiler is not designed so that only one type of computer can read it, any computer (that has the Java interpreter installed) can read and understand bytecode. The Java interpreter is sometimes referred to as the "Java Virtual Machine" ( Java VM for short) and some books even refer to it as the "Java run-time system". The interpreter on your computer takes the Java bytecode in the .class file, turns it into machine code which your particular computer can understand, and then executes (or "runs") the code.

You might wonder why the Java creators designed things this way - why use a two stage approach instead of just compiling or just interpreting the code like most other languages do? Well, the advantage is that once a Java file has been compiled, any computer with a Java VM can interpret and run that file. So the code is a lot more portable. Think about the huge number of network and Internet applications we run today - lots of different types of computers trying to communicate with each other. This approach overcomes these machine-dependency problems.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

chaithra rao, Welcome to the ranch !

Please take some time to check this.


[My Blog]
All roads lead to JavaRanch
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And credit your source.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation vs interpretation?