DDC
DDC

Reputation: 862

What are the compilers available that target JVM or CLR apart from javac or Microsoft's compilers for .Net?

What are the compilers available that target JVM or CLR apart from javac or Microsoft's compilers for .Net? Why don't we have compilers for popular languages like C, C++ that target JVM or CLR?

Upvotes: 0

Views: 1015

Answers (4)

Plenty of compilers exist that compiles to byte code, especially in the Java world, where the byte code level is on a very high level, so it is relatively easy to write a compiler for it.

For C the problem is that the abstraction of the machine needed by the compiled program is on a lower level than provided by the JVM. E.g. for pointer arithmetic to work you must have a single, large chunk of memory where everything is placed which is against the Java view of the world as a lot of independent objects.

It can be done, however. NestedVM solves this by compiling C programs to a MIPS-CPU with a custom runtime library. The generated code is then interpreted directly or as byte codes.

Upvotes: 1

Oded
Oded

Reputation: 499252

When it comes to .NET there is mono.

The fsf has a Java compiler as part of the GCC.

As for why there are no exiting compilers that compiler from C/C++ to the JVM/CLR - not sure this is the case, but apart from the massively different memory models, you need to recall that these languages are also partially specified by the accompanying libraries (say libc) - these are not small and also need to be converted, not a small feat either.

Upvotes: 3

Jon Skeet
Jon Skeet

Reputation: 1503040

Wikipedia has good information on this:

Why don't we have compilers for popular languages like C, C++ that target JVM or CLR?

Well, there's C++/CLI. Links:

Upvotes: 3

Lex Li
Lex Li

Reputation: 63264

RemObjects has Oxygene compilers for JVM and .NET (aka Pascal for Java and .NET).

http://www.remobjects.com/oxygene/

Microsoft does have VC++ compiler for CLR, but that is an extension to C++ (C++/CLR). Due to this fact, nobody tries to tailor C++ for JVM (as far as I know).

C is not an OO language, so unless heavily tailored (like C++/CLR), it is not suitable for JVM nor CLR.

Upvotes: 0

Related Questions