Over a million developers have joined DZone.

What I'm Missing in JavaFX 1.2 ;-)

DZone 's Guide to

What I'm Missing in JavaFX 1.2 ;-)

· Java Zone ·
Free Resource

OK, tons of new things in JavaFX 1.2, but of course we developers always want more! I'm not asking for major stuff right now, as I understand that the effort behind JavaFX is huge. But there's really a small thing, that I realize is missing right now: support for logging.

Of course I'm not talking of the desktop profile: you can use anything you want, from java.util.logging, to log4j or SLF4J. I'm talking of the mobile profile, where we don't have anything.

And, of course, you can write your own, and would be pretty simple. But look at this:

def x = 3;
logger.fine("x = {x}");

The problem is about performance. Even though the "fine" logging level is disabled, the JavaFX compiler will always first build the string parameter, converting x to a string, putting into the template according to the braces placeholder and then call the method, where it will be ignored. In contrast, SLF4J approach is smarter since when you write:

int x = 3;
logger.debug("x = {}", x);

you don't have any string manipulation before calling the method; instead, it is SFL4J code that inspects the string template and replaces the braces placeholder. Of course, only if the debug level is enabled.

Clearly, this is really important in the mobile profile, where every single piece of performance is needed; and polluting the code with "if (debugLevel) ..." is even worse than in Java, since JavaFX is so concise.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}