The three T’s JavaFX is missing Some more JavaFX surprises
May 14

In my earlier post I mentioned that JavaFX had some features I couldn’t understand or didn’t like all too much, and also promised to talk a bit about the new method JavaFX has for instantiating elements.

So, in order of writing in my post, here they are, my complaints:

  • What is this Extent for anyway? I don’t understand it. There is a feature in JavaFX which allows you to easily access all instances of a specific class. Yeepy. But what is it good for? What I see it replaces is a mechanism sometimes used where a class would register itself in an internal, static array (weak-referenced in Java of course). But where is it used?
  • Flat arrays: In JavaFX, arrays are not objects by their own right. They are treated differently, and they are also flattened out if inserted into another array. For that matter, there is no difference between [[1..100], 101..200]] and [1..200] and for a more severe example, [[f1, f2, f3], [f4, f5]] and [f1, f2, f3, f4, f5]. However, this is fine - Arrays are usually used this way, where most of the time we struggle with joining arrays together. This does prevent the usage of arrays of arrays to represent matrices, which can be quite frustrating.
  • Not JIT: As far as I understand, JavaFX is a scripting language running on top of an interpretation framework. This means that no JIT takes place, no optimization over time, etc. Obviously, eventually there are Java objects being called such as the Swing framework and Collections; however, the code itself is not being compiled to a lower-level state. I hope that’s not the case, but I couldn’t find anything to support any optimism. I just hope that just like Java started as an interpreted language and moved on to being JIT, this will too - Only with a shorter period of time.
  • JSON for object instantiation: JSON has its advantages and disadvantages. It is dead simple, with a simple syntax explained in a single HTML page. On the other hand, it is barely used and is not a common standard when describing hierarchies - That’s where XML is usually used. My guess is that XML was not very good for a scripting language syntax, and that JSON, being a language for JavaScript originally, was found to be more suitable for the task. I just wonder (and challenge you all!) when we’ll see an XSLT sheet transforming a graphical interface XML to JSON..
  • Inability to create enumerations: One of the newer, very much needed features in Java, enumerations are missing from JavaFX. And why? If JavaFX is supposed to be used to depict data models as well as graphical interfaces, why remove the best method to, for example, make a choice between Male/Female in a Person class, or Red/Yellow/Green in a TrafficLight class?
  • How do I extend my previous code: As much as I looked around, I couldn’t find a way to add binding abilities to classes outside JavaFX. After all, I am not expected to have all my application written in JavaFX. Some (and probably most) of my code will be behind the scenes, core-Java (use the right tool for the task, to quote a wise man). So, if I have some data model outside JavaFX which I want to bind to graphical elements inside JavaFX, how do I do that?

4 Responses to “The confusion JavaFX brings”

  1. Harry Says:

    Is this what you meant at the end of the paragraph on JSON?

    http://code.google.com/p/xml2json-xslt/
    http://www.bramstein.nl/xsltjson/

    Nice coverage, saves me having to wade through the JavaFX site,

    thanks! :-)

  2. Avah Says:

    Wow thanks! I figured there’d be something there… I guess I should’ve actually googled it up, but really just wanted to wrap up the post.

    So, thanks again!

  3. Chaotic Java » Blog Archive » Binding Java classes to JavaFX elements Says:

    [...] I’ve asked this questions before, but this is a more elaborate view on it. [...]

  4. Carl Says:

    >> So, if I have some data model outside JavaFX which I want to bind to graphical elements inside JavaFX, how do I do that?

    This is the same bummer I encountered. There are bindings to swing classes (or any rt.jar components), so it seems there should be a way…

    That said, if your application is a front end to an http server (chances are you are), you can use normal http protocols to pass the data back and forth to the server, such as xml.

    This is an area where Grails/Groovy can shine, because a lot of this is managed for you through controllers and implicit web-tear objects like Session. On the controller side you can work with persistent objects. None of this is unique to Groovy/Grails, of course. You can use Struts or Spring Web MVC, but Grails has a very nice Object-Relational Mapping (GORM) that easily works with Hibernate on the fly. You can then use POJOs at that point….

Leave a Reply

Chaotic Java is Digg proof thanks to caching by WP Super Cache!