views:

3507

answers:

5

I dont understand the difference between LLVM and the java (bytecode), what are they?

-edit- by 'what are they' i mean the differences between LLVM and java (bytecode) not what are LLVM and java.

+5  A: 

LLVM is a framework which can be used to develop front-end for languages like C++, C and others, backends for others, and other stuff i don't understand. For example, some respected members of the C++ community are working on a C++ frontend (called clang) based on llvm which will eventually replace gcc in future. llvm will glue it together with working backends (which generate machine code).

Java is a programming language, and a platform like .net. It's got nothing todo with llvm, expect that maybe one could implement a frontend for Java and a virtual machine interpreting java byte-code using llvm. (Yes, you can also write virtual machines using the building blocks provided by llvm).

llvm is written in very clean C++ code. I did have a look at its source some days ago, i like it.

Johannes Schaub - litb
+1 for honesty: "and other stuff i don't understand"
Tony k
+1  A: 

The difference is that one's a programming language and the other is a compiler-building framework. It's like asking, "What's the difference between a car and a rubber belt?" Well, one is a car and the other is a rubber belt. It would be easier to list the ways they're the same.

Chuck
LOL, 2 lusers downvoted with no comment. I stand by it. The entire question when I answered was, "I dont understand the difference between LLVM and java, what are they?" I answered that Java is a programming language and LLVM is a compiler-building framework. It's a succinct and accurate answer. If you don't want the question answered, downvote the question, not the answer.
Chuck
+23  A: 

Assuming you mean JVM rather than Java:

The LLVM is a low level register-based virtual machine. It is designed to abstract the underlying hardware and draw a clean line between a compiler back-end (machine code generation) and front-end (parsing, etc.).

The JVM is a much higher level stack-based virtual machine. The JVM provides garbage collection, has the notion of objects and virtual method calls and more. Thus, the JVM provides much higher level infrastructure for language interoperability (much like Microsoft's CLR).

(It is possible to build these abstractions over LLVM just as it is possible to build them on top of C.)

nimrodm
A: 

Java is a programming language, which uses the JVM as a means of "Just in Time" (JIT) execution, whereas LLVM is a compiler construction kit aimed at developing new languages and front-ends for existing languages. LLVM does have a JIT engine, but it need not be used if you don't require it. You could throw out LLVM assembler, byte-code or platform specific assembler instead of using JIT execution.

vext01
+3  A: 

It's too bad this question got off on the wrong foot. I came to it looking for a more detailed comparison.

The biggest difference between JVM bytecode and and LLVM bytecode is that JVM instuctions are stack-oriented, whereas LLVM bytecode is not. This means that rather than loading values into registers, JVM bytecode loads values onto a stack and computes values from there. I believe that an advantage of this is that the compiler doesn't have to allocate registers, but I'm not sure.

LLVM bytecode is closer to machine-level code, but isn't bound by a particular architecture. For instance, I think that LLVM bytecode can make use of an arbitrary number of logical registers. Maybe someone more familiar with LLVM can speak up here?

Owen
"I believe that an advantage of this is that the compiler doesn't have to allocate registers, but I'm not sure.". Not sure about that. ISTR the advantage is that stack-based is easier to verify.
Jon Harrop