Skip to main content

Java and the Computer Language Shootout

10 replies [Last post]
gmillermarket
Offline
Joined: 2007-03-08
Points: 0

Hello all,
I just posted a writeup on some analysis I did on Java's position in the Computer Language Shootout (http://shootout.alioth.debian.org/) on our blog, http://blog.marketcetera.com/. The short summary is that I think Java is getting shortchanged because of their choice of inputs and some of the more complex issues brought up in this article http://www-128.ibm.com/developerworks/library/j-jtp12214/ (admittedly quite old, but probably still applicable).

And we don't have any Google ads on our site, so we're not spamming, we really want to know what you think...

graham

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
spdenne
Offline
Joined: 2006-02-15
Points: 0

http://www.apfloat.org/apfloat_java/applet/pi.html
is an example of a fast pi digit calculator in java.

igouy
Offline
Joined: 2005-09-06
Points: 0

Try contributing a pidigits program that uses JNI to call GMP

Look through the benchmarks and if you see any show Nice or Scala programs significantly faster than the best Java program, then they are good candidates for improvement - try writing programs for those benchmarks in your own style (and profile them).

igouy
Offline
Joined: 2005-09-06
Points: 0

jwenting wrote

> that's well known. Such "comparisons" are often

> designed with the specific purpose of making Java

> look bad (or C look good, take your pick).


You've responded with a vacuous generality to a question about a specific comparison.


The comparison was not "designed with the specific purpose of making Java look bad". In fact, the comparison was adapted in a straightforward manner from Hans Boehm’s GCBench, which he said was “… designed to be more representative of real applications than other Java GC benchmarks …”.

Contribute better Java programs!

Nice and Scala compile to JVM bytecode and run on JVM - contribute a Java mandelbrot program that performs as well as the Nice and Scala mandelbrot programs.

atripp
Offline
Joined: 2003-07-15
Points: 0

See many of the responses to this post at Javalobby: http://www.javalobby.org/java/forums/m92082440.html

In short, the language shootout is completely bogus. Anyone can submit any program, the program need not even be written in the language that you say it is, need not use the same algorithm as the others, etc. They don't exclude JVM startup time. The people who run the site don't see these as problems, so just ignore the Language Shootout site.

igouy
Offline
Joined: 2005-09-06
Points: 0

[i]See many of the responses to this post at Javalobby:
http://www.javalobby.org/java/forums/m92082440.html
In short, the language shootout is completely bogus.[/i]

[i]Anyone can submit any program[/i]
You mean that any Java programmer who wrote better programs could just contribute them and make Java look better on the language shootout!
Dude that's so unfair!

[i]the program need not even be written in the language that you say it is[/i]
I guess someone could submit a C program pretending it was SML, and then when we would compile it with the SML compiler, and it would produce a whole list of compiler errors.

[i]need not use the same algorithm as the others[/i]
That's really wierd, the FAQ says the exact opposite!

"we ask that contributed programs not only give the correct result, but also [b]use the same algorithm[/b] to calculate that result"

[i]They don't exclude JVM startup time[/i]
Wow! That's actually correct, read all about it -
http://shootout.alioth.debian.org/gp4/faq.php#fullcpu

[i]The people who run the site don't see these as problems, so just ignore the Language Shootout site.[/i]
We certainly don't see the fake ones you invented as problems.

jeremygwa
Offline
Joined: 2006-01-17
Points: 0

Is there any way this code can be optimized some more, to show java's true glory?
At first glance, I thought of using exception terminated loops, but the loops never perform on an array, so that is useless.

is there any way to eliminate the i for (int i=0; i

Just a thought,
-Jer A.
__________________________________________________
[code]
/* The Great Computer Language Shootout
http://shootout.alioth.debian.org/

contributed by Isaac Gouy
*/

import java.math.BigInteger;

public class pidigits {
static final int L = 10;

public static void main(String args[]) {
int n = Integer.parseInt(args[0]);
int j = 0;

PiDigitSpigot digits = new PiDigitSpigot();

while (n > 0){
if (n >= L){
for (int i=0; i j += L;
} else {
for (int i=0; i for (int i=n; i j += n;
}
System.out.print("\t:"); System.out.println(j);
n -= L;
}
}
}

class PiDigitSpigot {
Transformation z, x, inverse;

public PiDigitSpigot(){
z = new Transformation(1,0,0,1);
x = new Transformation(0,0,0,0);
inverse = new Transformation(0,0,0,0);
}

public int next(){
int y = digit();
if (isSafe(y)){
z = produce(y); return y;
} else {
z = consume( x.next() ); return next();
}
}

public int digit(){
return z.extract(3);
}

public boolean isSafe(int digit){
return digit == z.extract(4);
}

public Transformation produce(int i){
return ( inverse.qrst(10,-10*i,0,1) ).compose(z);
}

public Transformation consume(Transformation a){
return z.compose(a);
}
}

class Transformation {
BigInteger q, r, s, t;
int k;

public Transformation(int q, int r, int s, int t){
this.q = BigInteger.valueOf(q);
this.r = BigInteger.valueOf(r);
this.s = BigInteger.valueOf(s);
this.t = BigInteger.valueOf(t);
k = 0;
}

public Transformation(BigInteger q, BigInteger r, BigInteger s, BigInteger t){
this.q = q;
this.r = r;
this.s = s;
this.t = t;
k = 0;
}

public Transformation next(){
k++;
q = BigInteger.valueOf(k);
r = BigInteger.valueOf(4 * k + 2);
s = BigInteger.valueOf(0);
t = BigInteger.valueOf(2 * k + 1);
return this;
}

public int extract(int j){
BigInteger bigj = BigInteger.valueOf(j);
BigInteger numerator = (q.multiply(bigj)).add(r);
BigInteger denominator = (s.multiply(bigj)).add(t);
return ( numerator.divide(denominator) ).intValue();
}

public Transformation qrst(int q, int r, int s, int t){
this.q = BigInteger.valueOf(q);
this.r = BigInteger.valueOf(r);
this.s = BigInteger.valueOf(s);
this.t = BigInteger.valueOf(t);
k = 0;
return this;
}

public Transformation compose(Transformation a){
return new Transformation(
q.multiply(a.q)
,(q.multiply(a.r)).add( (r.multiply(a.t)) )
,(s.multiply(a.q)).add( (t.multiply(a.s)) )
,(s.multiply(a.r)).add( (t.multiply(a.t)) )
);
}
}
[/code]

alexlamsl
Offline
Joined: 2004-09-02
Points: 0

Can't we rely on HotSpot's loop-unrolling?

igouy
Offline
Joined: 2005-09-06
Points: 0

> The short summary is that I think Java is getting shortchanged because of

> their choice of inputs and some of the more complex issues ...


What you find troubling is "the fact that for each benchmark results are only published for one set of inputs"

You are mistaken - we show results for 3 different input values. Every benchmark page has a “full data” link.

We are doing broad (lots of language implementations) and shallow (few input values) - we compromise on how many input values we measure because we put more emphasis on measuring many language implementations.

Those folk interested in just a few implementations should do as you have and measure many input values.

Of course it would be good if you said exactly how you made the measurements, and exactly what compile command were used - otherwise people will question whether you gave the -ccopt flags to ocamlopt etc

As for "some of the more complex issues brought up in" Brian Goetz's developerWorks article - see FAQ What does Full CPU Time mean?

jwenting
Offline
Joined: 2003-12-02
Points: 0

that's well known. Such "comparisons" are often designed with the specific purpose of making Java look bad (or C look good, take your pick).

gmillermarket
Offline
Joined: 2007-03-08
Points: 0

Is it well known what's causing the crossover at N=19? Really what these benchmarks are doing is measuring performance of particular combinations of language features. The binary tree benchmark happens to exercise the memory subsystem quite a bit, and I am interested in why the system behaves in such a way. Rather that just generalize about bad science, why not discuss the results?