Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

First steps with the JavaFX Compiler

 

Thanks to the efforts of Robert Field, Lubo Litchev, and Jonathan Gibbons of the Javac team, as well as Per Bothner and Brian Goetz (and also thanks to the organizational efforts of Bob Brewin, James Gosling, and Tom Ball) we have the beginnings of a JavaFX to JVM-byte-code compiler built on the same infrastructure as Javac.

Of course, the compiler is still incomplete, but it turns out to be far enough along to try a first performance benchmark (Takeuchi function):

import java.lang.System;

public class Tak {
  operation tak(x:Number, y: Number, z:Number):Number;
}

operation Tak.tak(x, y, z) {
   return if (y >= x)
       then z
       else tak(tak(x-1, y, z),
                tak(y-1, z, x),
                tak(z-1, x, y));
}

var tak = new Tak();
System.out.println("tak(24,16,8)={tak.tak(24, 16, 8)}");

$ time java -cp ".;dist/JavaFX.jar" TakMod
tak(24,16,8)=9.0

real    0m1.333s
user    0m0.010s
sys     0m0.020s

Here's the interpreter:

$ time bin/javafx.sh TakMod.fx
compile thread: Thread[main,5,main]
compile 0.04
tak(24,16,8)=9.0
init: 69.48

real    1m10.422s
user    0m0.190s
sys     0m0.130s
Speed improvement for this particular example is a pretty awesome 54x.