* Posts by JKing

1 publicly visible post • joined 23 Feb 2010

Oracle should cannibalize JavaFX Frankenstein

Thumb Up

You're ignoring the real power of JavaFX Script

Having a two-language approach (eg: MXML and ActionScript) works fine so long as your UI is largely static. But as soon as any variable content is introduced things start to get ugly. All the designer can do is place empty container nodes into the declarative code, so the programmer can later inject the dynamic content using procedural code. The power of JavaFX Script is it's an expression language, enabling the seamless mix of business logic and scene graph via a unified language that works well for both.

Quick example: say I need to display a list of up to five daily events in my UI -- on any given day there might be data enough for all five, or there might be none at all, we don't know until the code runs. A language like MXML, which lacks programmability and therefore variability, cannot handle this with grace. The only solution is to either allocate a rigid space for all five events regardless of whether they're needed, or use an empty container and have a programmer later inject the dynamic parts at runtime and rearrange the UI as necessary to accommodate them. Messy -- now your UI design is split across two separate programming languages and two different documents.

Compare that to JavaFX Script, an 'expression language' that's equally at home with declarative structure and business logic, and can switch effortlessly between the two as the UI is coded. In JFX I can blend programming constructs like FOREACH and IF blocks into the UI declaration, all in one document, using one language. (A simple FOR loop, placed at the relevant point in the UI structure, would be enough to elegantly solve the problem above.)

If you look at a lot of Flex applications the one thing you'll notice is they tend to be very rigid in their layout. You don't see many UI's that are customisable, allowing the user to organise their own toolbars, menus, views, whatever -- hardly surprising given the more flexibility you demand of a Flex UI the more fragmentation you get between the two schizophrenic methods being used to manufacture it.

One of the nice things about a unified language approach is not only can you declare a UI, but you can engineer its dynamic elements at the same time (and in the same place -- not a totally separate source file!)