Original URL: http://www.theregister.co.uk/2010/02/18/javafx_under_oracle/

Oracle should cannibalize JavaFX Frankenstein

Time to get Swinging

By Matt Stephens

Posted in Developer, 18th February 2010 07:02 GMT

Comment One of the survivors of Oracle's mammoth takeover of Sun Microsystems is JavaFX, the Flex wannabe and illegitimate son of Swing.

The biggest coup for JavaFX three years after its unveiling at JavaOne is its integration into Vancouver2010.com, in a spinning-wheel app that shows countries' medal counts dating back to 1924. It's a nice use of data visualisation, a cross between tag clouds and a time-traveling version of Risk. But oh my word, the jaggedness of the text. Don't these people know that Java can do antialiasing very nicely? Even the "Powered by JavaFX" logo has embarrassing color bleed.

The Winter Olympics app is a rare moment of fame for JavaFX, in an otherwise bleak and underperforming history. The brazenness of JavaFX.com suggests otherwise. It's all flashing lights and bold headlines, as if the marketing team are standing around Frankenstein's corpse sending shockwaves of electricity into it and insisting: "Look! Look! It lives! No, really, it does!"

JavaFX unfortunately failed because it was too little, too late. And yet Oracle has chosen to keep JavaFX going, in an attempt to invigorate its stillborn corpse. One wonders why.

Granted, there are things to like about JavaFX. The MediaBox component lets you very easily set up a streaming video in your web page. Just the following bit of code will do it:

var media = "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_11810873001_09c01923-00.flv";
var mediaBox = MediaBox {
    mediaSource: media
}

And then put it on your stage:

Stage {
    title: "MediaBox Player"
    scene: Scene {
        content: mediaBox
    }
}

This example, a live sample from their website, will play an excerpt from Big Buck Bunny - or any .flv file you happen to point it to, of course. The team has evidently taken on board the need for JavaFX to "just work", with a minimum of Daffy Duck-ing about. However, "just work" is exactly what this example didn't do in practice. With very little coaxing, the MediaPlayer locked-up with this impressive Windows Solitaire impression you see below.

My net connection was fine, but as soon as I scrolled the page a little bit, the picture went from Big Buck Bunny bouncing in the warm sunshine to an epic freeze, from which it never recovered. I'm not sure how exactly this will convince web designers to switch from the cosy safety-in-numbers (and stability) of their Flash players.

Missing mojo

There's actually a page crammed full of quite dusty mini-apps, each one giving the impression of a half-hearted Friday afternoon's tinkering, whipped out from under the developer's nose and slapped onto the website. Compare this with Adobe Systems' TourDeFlex, an integrated app packed with examples, none of which fail to impress. I can't quite put my finger on it, but somehow, Flex has the mojo and JavaFX doesn't.

JavaFX media player crash

Crashed player: the "just works" myth of JavaFX

I also feel that Sun/Oracle is missing their own key point: JavaFX is meant to be about reaching across different platforms, making the original Java premise of "Write once run everywhere" actually happen.

And yet if I load up Javafx.com on my Android phone, I get the full-size website and an invitation to download the 94MB NetBeans IDE for Windows. Never mind, I'll scroll diagonally down and try one of the sample apps. After all, the loud marketing insists that JavaFX apps run equally well on mobile devices as they do on the desktop. Again, no go. I'm pointed to a download page offering Java for Windows, Solaris, Linux or Apple. Could it be, then, that JavaFX is all about the marketing and very little to do with delivering on its promises?

For example, it's taken years for Sun to deliver a drag-and-drop UI builder, something which should have been there from the start. Even now it's still only in preview form.

Confession of a fanboi

In many ways, I'm a Java fanboi and it pains me to be so critical of JavaFX. As a technology, it should be granting Java a whole new lease of life. Instead it's stifling Swing development - which is where Oracle's efforts really should be now.

Swing is an integral part of the JDK, and it appears to be undergoing a renaissance in the jobs market. A quick search on jobserve.com reveals 60 new Swing jobs posted in the last seven days, in the London, UK-area alone. Let's compare this with the message I got on the number of new JavaFX jobs:

"Your search javafx returned no jobs and was changed to java"

Swing is a mature UI platform that doesn't deserve the neglect it's now receiving. What Oracle should do is slice out the good bits from JavaFX (there aren't that many), throw away the carcass, and graft them onto Swing.

Next, use the Java Virtual Machine's topnotch scripting support to integrate an existing scripting language (but not the quirky abortion that is JavaFXScript), one that supports Lambda-style functions (aka closures), making tasks like event handling and table cell rendering a breeze.

Oracle already has a top-class Swing GUI designer in the form of Matisse, which it's indicated it wants to make more generally available. Deployed applications are also WebStartable, and the Applet experience in Java 6 is actually pretty good. Swing is so strong, in fact, that I wonder why Oracle didn't just ditch JavaFX at the first gas stop on its new journey.

Unfortunately, while Oracle follow Sun's example and dithers about with the failing JavaFX, allowing Swing to languish and fall behind the times, developers will continue to migrate to Flex and the myriad Ajax toolkits. And Java will continue to be seen purely as a server-side platform. It's a shame, as Java had potential for world desktop domination there for a moment. ®

Matt Stephens is co-author of Use Case Driven Object Modeling with UML: Theory and Practice, and the upcoming Design Driven Testing: Test Smarter, Not Harder.