Sun engineer Chris Oliver introduces F3, a new domain-specific scripting language for constructing Java user interfaces. It is statically typed, provides compile-time error checking, has both Eclipse and NetBeans plugins, and supports both Swing and SVG. F3's main benefit is that it allows the rapid construction of attractive UIs with minimal code.
Among the more frequent criticisms of Swing is that creating sophisticated Swing user interfaces requires a lot of code, resulting in a complex codebase.
One solution to Swing's apparent complexity is JSR 296, the Swing Application Framework specification (see Artima's interview with JSR 296 spec lead, Hans Muller, A Framework for Swing). Among other approaches aimed to tame Swing's verbosity are domain-specific languages for UI definition. A promising new Java UI DSL is Chris Oliver's Form Follows Function (F3) language. Oliver, an engineer with Sun's SeeBeyond division, introduces this new language in a recent blog post, F3:
F3 attempts to demonstrate that we're not exploiting the full capabilities of the Java platform for GUI development and that together with supporting tools like F3, the Java platform is highly competitive with or superior to competing GUI development platforms such as Macromedia Flash/Flex/Open Laszlo, Adobe Apollo, Microsoft WPF/XAML, Mozilla XUL, AJAX/DHMTL... F3 fully supports Swing as well as Java2D. In fact, we have a translator that can translate most of SVG to F3.
Oliver demonstrates in his blog post several F3-based versions of visual appealing Flash and DHTML UIs, pointing out that the F3 version took much less time to write. He also gives snippets of F3 code to demonstrate the language's conciseness. The following code, for instance, draws a rectangle with rounded corners and different fill and border colors:
The most intriguing aspect of the F3 language is that it is statically typed, and provides compile-time error-checking. Presumably, the static typing also allows IDEs to perform refactoring of F3 code:
We have IDE plugins for both Netbeans and Eclipse Both plugins support as-you-type validation, code-completion, syntax highlighting, and hyperlink navigation (with control-mouse-over).
What do you think of Oliver's approach to making Java UI development easier? Do you believe that with a simpler domain-specific language, more developers would be interested in Swing?
The presented approach is a very good one, but it bothers me that it is a separate programming language.
I think Java needs some changes; more specifically, it needs the ability to be able to express trees in literal form. This would allow many tree-like constructs to be expressed directly in code, including GUIs, HTML pages, DB schemas, etc.