[followups set to comp.programming, since this has nothing to do with
the C language]
I'm not sure what the exact difference is between a bytecode and an
intermediate language... Perhaps Sun uses bytecode (TM) so Microsoft has
to call it something else?
The difference is subtle, and probably not important anymore. For the
most part .NET's 'intermediate language' and Java's 'bytecode' are
equivalent concepts.
Back when Java was young, bytecode was appropriate because the original
JVMs ran it directly (ie: it was their machine code). These days Java
bytecode is more often than not treated as an intermediate language, and
JIT compiling is used to translate that into native code for execution.
The way I understand it, .NET was designed from the bottom up to do JIT
compiling on CIL code. As such it's more correct (for certain values of
'correct') to call it an intermediate language.
But, seeing how machine code is just a language, surely you could write
an emulator for that machine code to run anywhere. Which would probably
be just as quick as a bytecode/CLR to execute.
And people have written emulators for various platforms. In effect a
JVM is an emulator of the Java platform, .NET and the MONO project are
emulators for the .NET platform, etc.
But that would be
exposed as a pretty dumb way of doing things, so why are virtual
machines so widely accepted? Can't you just get decent binary
compatibility (it works with C++, but early implementations were
incompatible with each other), and make your OS provide a sandbox?
C++ doesn't have binary compatibility between platforms. Never has.
The problem is that each platform has a number of major differences in
executable formats, different available APIs for doing the same thing,
various APIs that are available on one platform but not others, possibly
different CPUs with their own native machine code...
Creating a cross-platform standard for executables isn't going to
happen. Instead, Sun created a platform called Java, and provided
emulators for it to run on various platforms.
Does this mean a processor will eventually be able to execute CLR
instructions, if the whole world has to go .net?
There was talk a few years ago about Sun creating a Java CPU which could
be used to create an actual hardware+os implementation of the Java
platform. I don't know what became of it, but so far it has failed to
become a reality as far as I can see. Perhaps it was rendered pointless
by the vast improvements in JVMs.
I doubt that we'll see a .NET cpu any time soon.