Back in January I did a demo on JavaFX, Sun's declarative scripting language for creating rich media and content for user interfaces. I want to take a few minutes and tell you what I like and what I don't like from what I've seen so far. First of all, integration with existing Java libraries and the Java language itself is seamless. Everything works just like a normal Java object, and you can make any API call you need to just as you would in a standard Java project. In fact, you can have all your business logic be normal Java classes and just write you UI in JavaFX. Awesome! Secondly, static typing. I think it's cool to have a script-like language with static typing, because it better enforces the principles of design by contract. And again, this obviously resembles the Java language itself. Thirdly, the language constructs are designed to make building a UI much faster and easier. For example, anything you put inside a Do loop automatically gets executed in a background worker thread. You mean I don't have to create a custom override of SwingWorker? Yep, that's right. There are dozens of these nifty little language constructs and conventions that make life easier as a developer. Take the declarative syntax, much like the XAML model for the Windows Presentation Foundation: Instead of defining user interface properties and binding back-end data objects to components via a sequence of method calls, JavaFX script allows the programmer to declare the existence
of a user interface component (and any subcomponents) via an easy syntax and then declare that component's
value be bound to some back-end object property just using the keyword bind. From that point on, the UI component property and the back-end object property are fully two-way bound; when one changes, the other changes right along with it.
Ok, so what do I not like? Well, since in the declarative world program execution is not sequential, debugging support is more or less out of the question. This means we're left with trial-and-error to find out if our code works (or looks, I should say) as intended. However, your UI itself should not have a lot of complex code to it, so this is not a big deal. Another thing you will see is that a lot of the example and demo programs are partial recreations of flash websites, and the look really good, but they have to be run on the desktop. As of now, there's no way to compile this cool stuff into something the browser will understand. The best alternative at this point is to compile your FX app into a Java Web Start application. Unfortunately, we're still limited to HTML, javascript, and css to make things run in the browser. My understanding, though, is that JavaFX will become like applets. You'll write your UI in JavaFX, and embed it into HTML, much like the way flash applications work. It will run in the browser but hook into the consumer JRE for its true power. The proliferation of the standard JRE is quite impressive, and although this is all just speculation, I bet we'll see more examples like this in the near future.