3 ms·
Also, this is nice: "Java is an interpreted language. The JVM is the Java interpreter." Technically this is true. The JVM interprets Java bytecode in the sense
by sophist 18y ago
Also, this is nice: "Java is an interpreted language. The JVM is the Java interpreter."
Technically this is true. The JVM interprets Java bytecode in the sense that it translates the bytecode into machine language on the fly.
- jrockway 18y agoThe JVM doesn't interpret Java, it interprets JVM bytecode. Java isn't interpreted, it's compiled to run on the JVM (or natively). Basically, I'm in favor of a law that says "If you want to use the word compiled or interpreted in your blog post, you have to write a programming language first." That is the project you need to do to understand compiled vs. interpreted.
- deleted 18y ago[deleted]
- sophist 18y agoYes, I agree with you of course. But I think the intended audience for this blog would be operating on a slightly looser and less academic meaning of the phrase "interpreted language," where the answer to the question, "Does a Java program get interpreted when it runs?" would be affirmative.
- jrockway 18y agoBut so does any computer program. What do you think non-virtual machines do?
- sophist 18y agoThe difference is that binaries contain instructions that map directly to hardware operations, whereas bytecode is interpreted by a binary. The interpretation is an intermediate step that doesn't take place when a program runs on bare metal. edit: Of course, it would be possible to build a machine that actually executes JVM instructions directly. It would also be possible to build such a machine for JavaScript, but if someone asks you whether JavaScript is an "interpreted language," the answer would still be affirmative, even if there are cases where it's not true.
- rcoder 18y agoActually, at any given time, a large number of the "hardware" operations being passed to a modern CPU are actually being "interpreted" using the microcode implemented on the CPU itself. Even in the case of instructions which do map directly to hardware ops, the CPU is still doing branch prediction and prefetching, which implies that the code is being examined (i.e., "interpreted") before being executed. I'm not trying to say that performance isn't better when funneling native instructions down to the CPU; rather, just that it's worth remembering that there's really no such thing as "[running] on bare metal" any more, at least on a modern x86 ISA system.