Reply to Tortoise in Java vs C++

Perhaps Admin. made it read only so I cannot reply your post. I am no offense, but isn’t that byte code interpretted into machine code? .class is byte code, and when you run .class files, they are interpretted into machine code on the fly to memory. You don’t compile on the fly because it’s not a script language. The process you do to transform from .java to .class is called compile, the process the JVM translate from .class to machine code is called Interpret.

Correct me if I am wrong.

:wink:

I was just being a bit nitpicky, but there is a difference between compiling and interpreting. If you’re changing from one language to another that’s (generally) compiling. If you’re looking at the language and reacting to what it says, that’s interpreting. Modern JVMs take the bytecode and compile it to machine code. Similiar to how a traditional compiler for say C does, except it’s being done on the fly.

Java bytecode may not be a human readable language, but it’s still a language. They’re not machine code, so they have to either be interpreted (old JMVs) or compiled to machine code and let the computer interpret the machine code.

As far as I studied from University also Java Certification from Sun, Java compiles plain english into bytecode, then translates into machine code on the fly. You will never compile on the fly because compile is not an execution of commands. The JVM is to interpret, which is translating, from bytecode to machine language and execute the commands. If you compile on the fly, where do you get the compile error? If you get an error when you run a program, it’s called run-time error. From this, you can imply that compiling is to compile plain english into bytecode, and translating(interpretting) bytecode into machine code on the fly.

:wink:

To, er, avoid any further “interesting” interpretations of what “compile” and “interpret” mean with respect to running software I’d just like to chime in:

Interpreted languages use an interpreter which reads a sequence of non-hardware-native instructions and calls subroutines to execute each instruction. Machine code is actually interpreted by the CPU.

Compiled languages convert from one language into another language. This can mean compiling from Java to C, or from Java to bytecode, or from bytecode to machine code.

Machine code is an interpreted language; it’s interpreted by hardware, is the only difference. Quite often these days it’s even further compiled internally in the CPU into microcode which is even lower level than machine code and subsequently even faster when it’s read from a cache.

The Java Compiler is just that - it compiles the Java language into bytecode.

The Hotspot Virtual Machine is a hybrid interpreter and compiler. It performs honest-to-goodness interpretation of Java bytecode and calls machine code subroutines to execute byte code. After a little while it decides that some bits are best compiled, and it subsequently compiles the bytecode directly into machine code and caches it, shifting the onus of interpretation directly onto the CPU.

Why this is still a subject of debate is baffling, unless it’s some language quirk in non-native English speakers that’s causing an unforeseen confusion.

Cas :slight_smile:

To my understanding, interpretting is translating and executing instructions on the fly, and repeat doing that everytime the instructions are encountered.
A JVM usually interprets the bytecode until they are encountered a number of times. When they have been encountered a number of times, the JVM compiles that part to native machine code on the fly so that it doesn’t have to interpret them the next time.
This is called mixed mode execution (both interpretting and compiling).
That period in the programs execution is typically referred as ‘start up time’ or ‘warming up’.
After ‘warming up’ the important parts have been compiled to native machine code and no (or almost no) interpretting is done anymore by the JVM.
The reason you don’t get compiler errors during execution is because javac catches them before the code is run.

Somebody correct me if I’m wrong.

ah, Cas beat me to it with a much better explanation ::slight_smile:

[quote]To, er, avoid any further “interesting” interpretations of what “compile” and “interpret” mean with respect to running software I’d just like to chime in:
[/quote]
errr, ok. and I said…

“If you’re changing from one language to another that’s (generally) compiling. If you’re looking at the language and reacting to what it says, that’s interpreting.”

“…and let the computer interpret the machine code.”

Perhaps a tad on the vague side, but not incorrect nor “interesting”.

Yeah, not you specifically, but these threads are remarkable for popping up now and again and going over the same-old-same-old that should have been put to rest about 4 years ago. (That’s why it got stomped on by the mod)

Cas :slight_smile:

[quote]Yeah, not you specifically, but these threads are remarkable for popping up now and again and going over the same-old-same-old that should have been put to rest about 4 years ago. (That’s why it got stomped on by the mod)
[/quote]
So I wonder, when are those pointless code formatting discussions finally get stomped on? ::slight_smile:
At least the C++ vs. Java discussions are still somewhat valid and current (the C++ vs Java discussion even took place in a recent JDJ article ;)) and these aot compiling vs. jit vs. interpretting vs. mixed mode issues are still likely to cause confusion.

Well, the issues may cause confusion, but they probably don’t need to be repeated again and again and again here and over at the jdc forums and every time Slashdot mentions java and that’s just the ones I occasionally visit.

Most forums have a “search old threads” facility and I like to think they exist for a reason, it just gets tiresome to see the same old issues dragged up time and time again by new generations of the lazy and ignorant who can’t be bothered to check whether their question has been answered before. Then again, I suppose that is like a microcosm of human history, so I guess its unlikely to change any time soon :wink:

(quick aside on that search idea)
Nearly all forums exist for the moment, with things becoming relevant then fading into obscurity all the time.
Generally speaking the search functions on flat forums, like this one, are useless. They often don’t find good results; they often find irrelevant results; they usually find stuff that’s actually out of date anyway.

That’s why these things keep surfacing.

Without a nice threaded GUI and proper moderation flat forums are of limited use but they’re the best thing we generally have on the web. Lowest common denominator and all.

Cas :slight_smile:

Hmm, so what we need is a way of archiving discussions in prose form, preferably with no moderator intervention. Once it starts getting full it would become a useful archive for new users to peruse.

If we could get something like that, it’d be WIKId. :stuck_out_tongue:

You mean something like this
http://wiki.java.net/bin/view/Games/WhatMeansCompileAndInterpret
:slight_smile: ?

Heh, that’s nice :slight_smile:
Of course this won’t prevent these discussions from popping up every now and then, but they can be put to rest quickly by pointing them to such a link.

Perhaps we should upgrade to gossamer threads (GT) Forum or similar? I’m not raving about GT at the moment, but we’re adopting it for a game at the moment precisely because it does things like threaded discussions (and some other features that aren’t really relevant to this discussion…).

www.gossamer-threads.com

Arrgh! Not another “new forum software” thread… ;D

::slight_smile: