Wednesday, June 27, 2007

JavaFX

So JavaFX is my new favorite programming language. Thats right - JavaFX is a new programming language.

I think a lot of people might be getting the wrong idea about JavaFX because of the marketing hype. When I first heard about JavaFX, it was positioned as an alternative to Flash (or Flex). As a way to create (and deliver) Rich Internet Applications. But upon further inspection one realizes that, at its core, JavaFX is really a new language that runs on the JVM. I would say that comparing JavaFX to Groovy (or even Spring) would be more appropriate than comparing it to Flash.

[Correction: Technically speaking JavaFX is a brand - JavaFX Script is the name of the programming language.]

I'm low on time right now and can't go into many details, but let me say this: JavaFX is not just another language that runs on the JVM, its a very cool language. By cool, I mean that JavaFX has a number of innovative features that produce immediate and pronounced payoffs. For example:

1. Type-safe JSON
Any one who has used languages like Ruby or Groovy or even JavaScript knows that those languages don't need all those damn XML files that are part and parcel to modern Java frameworks.

Essentially, any language that has syntax for array literals PLUS map literals has built-in support for declarative, XML-ish constructs:

For example in JavaScript:

var company = {
name: "Smart Soft",
url: "www.smart-soft.com",
people:[
{firstName:"Dave",lastName: "Ford"},
{firstName:"Michelle",lastName: "Goldstein"}]
}

Now JavaFX has this same feature - but with one distinct advantage: the map literals are not maps - they are typed Java objects. Here is how this would look in JavaFX:

var company = Company{
name: "Smart Soft"
url: "www.smart-soft.com"
people:[
Person{
firstName:"Dave"
lastName: "Ford"
},
Person{
firstName:"Michelle"
lastName: "Goldstein"}
]
}

This "typed" feature means that the IDE can give you auto-completion and find your errors sooner rather than later. Bottom line: integrated declarative-style programming + type-safe IDE auto-completion and early error detection = big productivity gains.

2. Language level support for bi-directional data binding. This is analogous to JSF's "value binding expressions" or Microsoft's "bound controls". The data binding feature supports MVC architectures in the most elegant manner I have seen yet. You simply declare that a particular UI text field is bound to some field in your model object. And then JavaFX keeps the model and view in synch automatically.

There is much more to JavaFX than I have mentioned, but this should give a you a basic feel.

1 comment:

John Clingan said...

JavaFX does look interesting. I can't wait to see what the community does with it.

FYI, JavaFX is an umbrella brand. JavaFX Script is a language. JavaFX Mobile is the mobile platform.

John Clingan
GlassFish Product Manager