May 8, 2007

Sun announced JavaFX which inventor Chris Oliver describes in his blog.

My project is called F3 which stands for “Form follows function”, and its purpose was to explore making GUI programming easier in general.

F3 is actually a declarative Java scripting language with static typing for good IDE support and compile-time error reporting (unlike JavaScript…), type-inference, declarative syntax, and automatic data-binding with full support for 2d graphics and standard Swing components as well as declarative animation. You can also import java classes, create new Java objects, call their methods, and implement Java interfaces.

F3 was the original name for what is now JavaFX. Apparently Sun/Java/JavaFX has thrown its hat into the ring to battle newly announced Microsoft/Silverlight and Adobe/Apollo/Flash.

JavaFX is a scripting language but it is not Javascript running in the JVM…. no sir. In fact the term BIZARRO comes to mind. BizarroScript maybe. It certainly has some great features but I think it will take a while to get my head around some of the language features. So first of all, JavaFX is not a video player. It is basically the equivalent of XAML with the application described in BizarroScript rather than XML.

So what makes JavaFX easy to read/write is Object Literals. Lack of Object Literals has always been a knock against Java. So JavaFX at a minimum allows you to describe GUI layout in a very readable Object Literal format like so:

Frame {

   title: "Hello World F3"

   width: 200

   content: Label {

      text: "Hello World"


   visible: true


Very JSON-like. Then you get BizarroScript stuff. Functions that can only contain variable declarations and a single return statement (multi-statement procedures can be written in something they call “operations”). Operators ?, +, and * to specify the cardinality of types (e.g. “var nums:Number* = [1,2,3];”) Arrays with XQuery-like expressions (think SQL for arrays) with insert and delete statements. Select statements (list comprehension) for arrays. A powerful variable binding mechanism that forms the basis for a model/view pattern. Oh, and let us not forget Update Triggers that are SQL-like events that fire when class attributes change.

BizarroScript indeed, but much more comprehensible than the language features in C# 3.0 needed to support LINQ (similar to the XQuery-like expressions in JavaFX but more powerful). I like it.