Upgrade status: still ongoing: WIMS. Please alert the webmaster about any anomalies.
You are here: Foswiki>Cosmo Web>ComputerLanguages>JavaVirtualMachines (14 Nov 2003, MichalFrackowiak)Edit Attach


Java Virtual Machines (JVM) and compilers

which one to chose?

When choosing to use Java as your programming language there is always the choice of a particular implementation of Java. There are a few choices. What is nice is that they are absolutely free (free as in "free beer", but not as in "free speech" http://www.gnu.org/philosophy/free-sw.pl.html) but does not mean they have to be open (-source). You can use them for any purpose you want - see the corresponding licences. In that sence they are free. (This is freedom 0 of the 4 freedoms listed at http://www.gnu.org/philosophy/free-sw.pl.html). However, Java itself is a trademark of Sun Microsystems and that is Sun that is in charge when it comes to extend the language, introduce new specifications etc.

One more word about what you need to write your Java soft and what is the JVM itself. Java is different from compiled languages like C, C++ or Fortran. Those languages are compiled to the native code that can be executed directly by the computer. With Java it is different - source code is compiled to the bytecode - universal code that can be executed by the Java Virtual Machine, NOT the computer/cpu itself. So there is one more step. JVM's role is to translate the bytecode to the native code so it can be executed.

Very old JVMs where just interpreters and very very slow. Modern JVMs use diffrent technologies like HotSpot or JIT (Just In Time compiler). The bytecode is being compiled "on the fly" (JIT) to the native code and thanks to HotSpot it is also very wisely optimized (main rule is that the most commonly used code is optimized the most, depending on the usage - this is certainly big advantage over "static" optimisation of native-code compilers which does not have to be smart). In fact modern JVM performance is comparable to C/C++.

Why bytecode? The idea of Java was to compile once - run anywhere. Your compiled soft can be run on Linux, Mac, Windows... anywhere you want without any change provided there is a JVM on the computer. This is the best portability you can have.

And here is the choice:

Sun J2SE (Standard Edition is what you want. Currently ver. 1.4.2)

The reference implementation, quite nice but not the speed-deamon. Features JIT and HotSpot. If you want to start with Java - this is certainly what you need. http://java.sun.com - and many specifications/tutorials/forums etc. to downlad go to j2sdk (soft. development kit)

Blackdown Java (v. 1.4.1)

Blackdown is an organisation that is porting Sun's Java to Linux. In fact the SDK you can get from Sun's website is based on the Blackdown's version. I can not see any big reason for using this version. http://www.blackdown.org

IBM SDK (currently v. 1.4.1)

Certainly the fastest JVM you can find! And that is the one that is suitable for numerical works! Features the best JIT technology which is supreme over Sun's version. In benchmarks such as Scimark2 the mean performance is about 150%-180% (sic!) of the Sun's JVM. Some tasks go even 4 times faster! In everyday-use there is also a nice boost in speed. Highly recommended! What is really nice is that Scimark2 in Java and in C give almost the same results when using this JVM!!! http://www-106.ibm.com/developerworks/java/jdk/linux140/

WebLogic (JRockit)

Targeted towards bussiness application. On several Linux platforms has problems with pthreads. Performance is not that high as they claim it to be. Just forget it. Licence is very not clear.

Kaffe (hard to determine the version. the project is lazy.)

Open-Source and 100% implementation of Java. But since Java is a trademark, it is not Java from the formal view. Does not matter. What matters is that there is a development version that is quite nice. But I do not recommend using it. It is very slow, not extremely stable. The only + is that it is 100% free and open. Scimark2 gives results 4x lower than using Sun's JVM. No surprise - does not have JIT. I do not believe they can keep pace with the rapid development of Java. If you have a lot of time - any contribution should be welcomed. At least try it with your own software and see how it works. http://www.kaffe.org

Jikes - open-source, free - compiler only (no jvm)

Extremelly fast (the fastest) compiler java source -> bytecode. If you have a biiiig project or a project that requires rapid compilation - that is for you.

gcj - native-code compiler. Java interface for gcc

This one is worth attention for sure! Gcj can compile both .java sourcefiles and .class bytecode to native code. So what you get is an executable. Just like C or Fortran. Quite nice performance, but still comparable to Sun's JVM. What is very attractive is that it is 100% free and GPL (free as in "free speech", all four software freedoms). Does not recognize all the Java features. Is against portability. However it compiles my numerical software wink But is not stable - compiled software sometimes throw Exceptions (in my case) which does not happen when using other JVMs. But uses much less memory that JVMs.

What I found out is that disabling some checking (options to the compiler) the code can be as fast as the one executed on IBM's JVM. Disadvantege is also lack of Swing - graphics interface. So you do not get a complete java. But if you already have some software of your own - try this out as it deserves attention.

My (Michal Frackowiak) recommendations:

If you start with java, get Sun's version. There is no problem in switching later. Forget Kaffe, do not care about gcj for now. Treat it as sth interesting - you can experiment with it. Than switch to IBM's JVM as soon as possible. You can use Jikes as your compiler, but for me it is certainly not necessary. Rather than experimenting with JVMs - as me wink - start writing good software with good documentation! wink

Some notes

The not-a-very-nice-thing is that open-source and community-maintained code does not compete well with solutions provided by the "bigfish". The nice thing with it is that Sun and IBM put a lot of effort to bring what is the best for Java. And results can be seen - a few years ago Java was considered a terribely slow language. Some people still believe it. There are many disadvantages of Java but certainly it is not slow!

Although Java is not free as "free speach" it can be a great development environment. There is a LOT of free (open-source, GPLed etc) software suited for developers (e.g. http://www.eclipse.org). Java (and JVMs) is being actively developed and becomes better and faster with every new release.

Certainly writing a dast code depends on the developer. One has to be aware of the fact that some goodies of object-oriented programming cost a lot of memory/time although it is hidden behind the scene. Once realising it - there comes a way to develop fast, stable, portable, nice-documented software. I hope!

-- MichalFrackowiak - 13 Nov 2003
Topic revision: r6 - 14 Nov 2003, MichalFrackowiak
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback