Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>... where everybody has a compiler specific for their platform. So the advantage isn't explained by that.</p> </blockquote> <p>Porting code written in for example C or C++ is almost always <em>much</em> more involved than simply recompiling the code. It's certainly not something that an average, non-developer computer user can do easily. Code written in compiled languages is very often written against the API of a specific operating system (the Win32 API, for example) and so it cannot be compiled on other operating systems easily.</p> <p>Java bytecode runs on any platform where there is a Java runtime environment available. The code doesn't need to be recompiled. Ofcourse you can write operating-system specific code in Java, but Java's standard library, and the many free libraries available on the web, provide a very rich cross-platform environment.</p> <p>Besides portability, running on a virtual machine has other advantages. Java uses a <a href="http://en.wikipedia.org/wiki/Just-in-time_compilation" rel="noreferrer">JIT compiler</a> to compile Java bytecode to native machine code at runtime. The JIT compiler can do sophisticated optimizations for the specific CPU that the program is running on and it can use profiling information that wouldn't be available to an ahead-of-time compiler - in principle, a JIT compiler can therefore produce more optimal code than a "normal" compiler.</p> <p>Besides the Java VM, there are other virtual machines. For example, Microsoft .NET contains the <a href="http://en.wikipedia.org/wiki/Common_Language_Runtime" rel="noreferrer">CLR</a> (Common Language Runtime) and there's also <a href="http://en.wikipedia.org/wiki/Low_Level_Virtual_Machine" rel="noreferrer">LLVM</a>, which has front-ends for many different languages including C and C++ (and which is supposed to bring the advantages of JIT compilation also to C and C++).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload