Turbo Java

I always write a simple Wright-Fisher simulation when I’m looking at a new computer language (the Wright-Fisher model is a cornerstone of population genetics). I tried several languages; C, C++, Java, C#, Python, even MatLab and Maple… It’s my “hello world!”.

For fun I tried to run the programs on my openSUSE partition. Very boring; all programs are as fast on openSUSE as they were on WindowsXP. With two exceptions. The first isn’t very surprising = C# is faster on Windows (34s for WinXP vs. 40s with Mono on OpenSUSE). To be more accurate; it’s a little slower with Mono.

But then… Java. The programs takes 40s on WindowsXP, which is just as expected. From my experience Java is nearly always a little slower than C#. On openSUSE, surprise ! 24s !

Can someone explain to me how openSUSE can make Java so freaking fast ?

You know the joke:
*-Knock knock
-Who’s there?
Very long pause…
-Java

It depends on the JVM implementation. It’s different on Linux/Windows architecture of course. It also depends on preloaded classes, packages, etc…
Java gives you a very useful tool called JConsole. It shows example: how many memory uses the JVM, the number of preloaded classes, heap memory, CPU usages, etc. Start it, and find out what’s the difference in Linux/Windows.
Good luck.

On Fri, 2009-04-17 at 03:06 +0000, Shinka wrote:
> I always write a simple Wright-Fisher simulation when I’m looking at a
> new computer language (the Wright-Fisher model is a cornerstone of
> population genetics). I tried several languages; C, C++, Java, C#,
> Python, even MatLab and Maple… It’s my “hello world!”.
>
> For fun I tried to run the programs on my openSUSE partition. Very
> boring; all programs are as fast on openSUSE as they were on WindowsXP.
> With two exceptions. The first isn’t very surprising = C# is faster on
> Windows (34s for WinXP vs. 40s with Mono on OpenSUSE). To be more
> accurate; it’s a little slower with Mono.
>
> But then… Java. The programs takes 40s on WindowsXP, which is just as
> expected. From my experience Java is nearly always a little slower than
> C#. On openSUSE, surprise ! 24s !
>
> Can someone explain to me how openSUSE can make Java so freaking fast ?

Well… not only are their multiple variants (e.g. IBM vs Sun)… but
there is a gazillion tweaks. For example if running java in a more
client config centered mode, it will startup faster… but if the thing
is a server java program, tweaks will be needed to make it run
efficiently for scalability… which will likely dramatically slow
down the initial startup time.

Java reminds me of ADA. It’s more of an operating environment (sort of
like an OS) rather than a programming language. Which makes sense
since the goal is “write once, run anywhere” (which personally I’ve
never seen work really well… which is why Java has such a bad
rep).

Will I dear to pronounce the words??

No, it isn’t Java that sucks. It’s Windows!

Now, seriously. Since the beginning Microsoft has tried to fight against Java. At first they created “their own java” (Microsoft VM anyone?), and finally they created that nasty monster, .net. The “write once, run anywhere” does not fit their business model at all.

It has never suriprised me that Java performs better on any OS than it does on Windows: they have never “shared” the OS’s hidden features (optimization) which they reserve for their own products. Do not forget this company has been sentenced for monopoly practices before.

Well written Java programs can approach the speed of C/C++ programs. However, handling GUI in Java is not very efficient with their AWT/Swing classes. The Swing code is very pathetic. When I went through their source code, I found various things that can affect efficiency.

The way memory is managed under Windows OS is not very suitable for certain applications. I have read a design document of a Java based application to manipulate Excel files (not the apache POI project, but a proprietary one), and they had to struggle a lot to make the application faster under Windows - yes, it was much faster under Linux.