Does Crafty or Stockfish or Komodo, going to Java?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Bo Persson
Posts: 260
Joined: Sat Mar 11, 2006 8:31 am
Location: Malmö, Sweden
Full name: Bo Persson

Re: Does Crafty or Stockfish or Komodo, going to Java?

Post by Bo Persson »

bhlangonijr wrote:
rbarreira wrote:
bhlangonijr wrote:
rbarreira wrote:
bhlangonijr wrote:The JVM itself is written in C++ how could it be faster?
The JVM is a compiler, it could even be written in BASIC and the compiled Java code might be faster than anything.

Of course, we all know that in general Java is definitely not faster than C or C++.
Where did you get that the JVM is a compiler? The JVM is the Java Virtual Machine and is responsible for running the Java bytecode (the compiled artifact). The compiler is present in the JDK which is not required for executing the Java binaries.

Regards,
I believe that most important JVM's compile the compiled bytecode into actual machine code for the architecture being used.

Some JVMs may not do this, but the ones for the most popular architectures / OSs certainly do. If bytecode emulation was always used, Java programs would run MUCH slower on those computationally intensive benchmarks instead of two times slower and similar.
The HotSpot VM does that. IMO it is more like a "feature" present in most VM's to improve performance. Although it doesn't make the JVM a "compiler" itself.
The point I was trying to make is that there is a middleman between the Java code and the machine code and it was actually written in the language C++. So how could we expect Java to be faster than C++?
Or more portable?

:-)
Mangar
Posts: 65
Joined: Thu Jul 08, 2010 9:16 am

Re: Does Crafty or Stockfish or Komodo, going to Java?

Post by Mangar »

Hi,

some time ago Spike had a source code that could be compiled by a Java compiler and a C++ compiler. We had a little search & replace program for some code pieces as not all could be handled by macros.

Java took about 1.6 the time as C++, using a just in time compiler used for server applications.

The factor 1.6 is mainly coming from array access range checks. Spike use a lot of array access. Java tests if the index is inside the range (two tests) before reading from the array. IMHO the main difference in speed is there.

There is no reason to use Java instead of C++.

Greetings Volker
Mangar Spike Chess