Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: So how's Java these days? Still slow?

Author: Ralf Elvsén

Date: 13:40:55 05/09/02

Go up one level in this thread


On May 09, 2002 at 10:33:52, Russell Reagan wrote:

>I've recently started learning Java, and I am curious how suitable it is for
>writing a chess program in comparison with C or C++. The main issue would seem
>to be that Java has generally been seen as having a significant performance hit
>when compared with compiled C or even compiled C++. I think a lot of things in
>the computer world get a bad reputation if they have some drawback when they are
>initially released. So is this still a major issue today? I like a lot of things
>Java has to offer, and it seems like I could develop a program quicker in Java,
>and at the same time write a portable GUI for it, make it playable from a web
>browser, and so on.
>
>Having said all of that, I'd still like to have a good chess program and
>eventually enter it into some of the amateur tournaments like maybe CCT5 (if and
>when that occurs). So would I be making a mistake by choosing Java due to it's
>lack of raw speed in comparison to C or C++, or is this not that big of a deal
>unless I'm going to be overly concerned with super-optimization way down the
>line?
>
>In the book, "Java in a Nutshell", the author writes: "Although early releases
>of Java suffered from performance problems, the speed of the Java VM has
>improved dramatically with each new release...Java programs can execute at
>speeds comparable to the speeds of native C and C++ applications." So while this
>is true for some applications where performance isn't even an issue, like maybe
>a word processor, is this true for a chess program or other game playing
>programs?
>
>Thanks,
>Russell

I have written chess programs in Java and in C. My estimate 2 years
ago was that the speed difference was a factor 1.5 - 2. Bear in mind
that this is no accurate measurement, just an estimation. Peter Kappler,
who has a Java-program Grok, mentions numbers in the same range.
I guess it can depend a lot on the program as well.

For other types of applications, who spends most of their
time in small tight loops, I have heard that there are often
no difference at all. I don't know enough to explain these
differences (if such they are). Remember: if you write a chess
program in Java, don't create any objects in the search with the
new-operator. It will slow you down significantly
(just as malloc would). But there is no reason to do so,
you can organaize your data just as in a C-program.
Garbage collection is not an issue.

And check out different compilers. Peter Kappler has recommended
IBM's, but that was some time ago. And yes, portability and GUI-
development is pretty nice.

Ralf







This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.