Sun's JavaFX: Is it Java? JavaScript? Or something new?

By Scott M. Fulton, III | Published December 10, 2008, 4:01 PM


Download JavaFX for Windows (all versions) from FileForum now.

We're told that the future of applications relies on app servers and rich, graphical clients. But will market share or common sense determine which method of building RIAs that developers choose most?

All the major rich Internet applications platforms that are in active use today are leveraged upon some existing, already well-deployed component. Adobe's AIR relies on the ubiquity of Flash video and the underlying language constructs that have supported Flash in the past, such as Flex. Microsoft's Silverlight is a vehicle for extending a part of the .NET Framework and Common Language Runtime -- and thus with them, a little bit more of Windows -- into everyone's computing environment; and once Microsoft secures that open pipeline, it may be able to push C# and other technologies through it.

Up to now, Google has been the one with the RIA platform that has tried to leverage Java, along with JavaScript (which is related in style but not in architecture, and which is essentially a product of Mozilla). Google Web Toolkit uses Java tools as a staging ground for Asynchronous JavaScript (AJAX) applications. Mozilla has been testing the waters for some time with its own RIA platform experiment called XULRunner; and Curl has had the wherewithal to go it alone, with both a development environment and a runtime that rely on no single pre-existing platform. (Some dispute whether AJAX truly qualifies as RIA, but I tend to say that if an application can run outside the browser with full graphical resplendence, as though it had been installed on the user's computer directly, then it's an RIA.)

To this mix of players, enter Sun Microsystems. Its JavaFX platform formally exited beta on Monday, and its objective is to further extend the Java 6 runtime platform onto more systems. Rich graphical applications built with JavaFX, like other Java apps since the 1990s, can run outside of the Web browser though maintain their links to servers through HTTP.

But JavaFX Script -- the programming language for this new platform -- is not Java, and it's not JavaScript. While it's not exactly a foreign language, especially for Web developers who find themselves learning new ones practically every month, it is -- like Flex for Adobe -- its own beast.

An example application using Sun's JavaFX
In this sample JavaFX application running in Java 6, a series of thumbnails can be browsed like a certain familiar long list of square covers, with each cover transforming itself in 3D and smoothly scrolling.

Rather than rely on some XML-based resource to define the appearance of on-screen objects, JavaFX Script uses an entirely new declarative language. In Java itself, you may use functions as a way of generating graphic objects, and arguments to those functions as ways of loading elements of those objects with text and values. By comparison, in JavaScript, you rely on XHTML markup to generate the placement and content of objects, which then sets up the environment for the events necessary that JavaScript can respond to with event functions.

With JavaFX instead, you declare the existence of graphic objects, which have very replete lists of properties. Rather than saying those properties are "equal to" their contents, as you might with a procedural language, you specify each property and its value or content using a colon (:).

Here's an example of a typical JavaFX Script code element: in this case, a clause that represents the placement of a Frame control, along with its default parameters, inside a JavaFX application's window. It's an excerpt from a tutorial article by Anghel Leonard, published last year by O'Reilly:

Frame {
 centerOnScreen: true
 visible: true
 height: 230
 width: 300
 title: "Capture the screen..."
 onClose: operation() {System.exit(0);}
 content: ScrollPane {
 background: white
 view: Canvas {
 background: black
 cursor: DEFAULT
 content: CaptureExample
 }
 }
}

It is not at all difficult to understand; what may become a little precarious for many new developers will be adjusting to all the new habits, and the new way of working. Contrast this method of development against Microsoft's, in which you would develop a control using a graphical environment, but the product is a graphics resource file using that company's XML scheme called XAML.

JavaFX utilizes the new NetBeans 6.5 IDE, which is now especially geared for Java and JavaFX. As with all its developer tools, the only investment Sun asks of you is your time and patience.

Comments

View comments by with a score of at least

The code example provided is extremely outdated; for example, there is now no longer a difference between an operation and a function. They're all called functions now.

Score: 0

|

This is YAP (Yet Another Platform) that is entering a crowded, full marketplace. We didn't need silverlight when silverlight entered the scene, nor Adobe AIR, and certainly not this.

I'm going to hold out on this, but we all know that a JRE is going to include it one of these days, or open office will. sigh.

Score: 0

|

... "along with JavaScript (which is related in style but not in architecture, and which is essentially a product of Mozilla)."

JavaScript is a product of Mozilla? This assertion would surprise a few people at both Netscape (RIP) and Mozilla.

Score: 0

|

This one is DOA.

Score: 0

|

Microsoft's Bob Muglia and Ray Ozzie on Silverlight vs. standards

Bob Muglia: "We're trying to provide people with an environment that has capabilities that you just simply can't do today in the standards-based world."

Uh-oh, netbooks -- not Windows 7 -- will lift 2009 PC sales

Santa may bring a lump of coal to the Windows PC industry this holiday season. Netbook sales will sap PC margins, while weak Windows 7 PC sales could further drive down average selling prices.

Google's value proposition for Chrome OS: Should we feel insulted?

For a search engine that has direct access to all the world's online history, it appears to have taught Google nothing about selling a machine.

PDC 2009: What have we learned this week?

There was the freebie that no one will forget, the heebie-jeebies courtesy of Scott Guthrie, and a teensy bit clearer picture of how this cloud thingie should work.

Where there's smoke: Apple warranty stance raises troubling questions

Carmi Levy | Wide Angle Zoom: Smoking can be dangerous not only for your lungs, it appears, but for your Apple hardware warranty.

Microsoft's .NET Micro Framework is now free and open source

The latest version of Microsoft's .NET Micro framework is now in the hands of the FOSS community.

E-book readers will be in short supply this holiday season

E-readers are hot this year, and a lot of compelling new products have been released, but are there enough electrophoretic displays to go around?

Sony looks to finally open a single storefront for downloads

Sony has had many different download portals for movies, music, e-books, and games, and now it's looking to make a single shop for all of it.

Tuning out the tablet: Time to give the endless speculation a rest

Wide Angle Zoom: Wishing and hoping and thinking and praying....won't put an iTablet on the market.

Five improvements for IT managers in 2010

If businesses are to improve their efficiency for next year, they need to stop and reassess the basic tenets of their job.

Live report: Will Google Chrome OS change Linux?

The mysteries of just what Chrome OS is, and how much of an operating system it truly is, may be resolved today.