The Artima Developer Community
Sponsored Link

Java Community News
Chris Oliver on Form Follows Function (F3): A DSL for Java UIs

1 reply on 1 page. Most recent reply: Nov 13, 2006 6:27 AM by Achilleas Margaritis

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Chris Oliver on Form Follows Function (F3): A DSL for Java UIs Posted: Nov 10, 2006 2:42 PM
Reply to this message Reply
Summary
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.
Advertisement

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:

import f3.ui.canvas.*;
import f3.ui.*;
Canvas {
    content: Rect {
        x: 20
        y: 20
        height: 80
        width: 300
        arcHeight: 20
        arcWidth: 20
        fill: cyan
        stroke: purple
        strokeWidth: 2
    }
}

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:

F3 is actually a declarative Java scripting language with static typing for good IDE support and compile-time error reporting (unlike JavaScript...), type-inference, declarative syntax, and automatic data-binding with full support for 2d graphics and standard Swing components as well as declarative animation. You can also import java classes, create new Java objects, call their methods, and implement Java interfaces.

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?


Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Chris Oliver on Form Follows Function (F3): A DSL for Java UIs Posted: Nov 13, 2006 6:27 AM
Reply to this message Reply
The code reminds me of Smalltalk:


rect set x:100 y:100 width:200 height:200


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.

Flat View: This topic has 1 reply on 1 page
Topic: Chris Oliver on Form Follows Function (F3): A DSL for Java UIs Previous Topic   Next Topic Topic: A Parade of New Features Debuts in Python 2.5

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use