|
|
Well, let me first tell you that it was intentional.
F3 is based on the idea that XML is not an effective syntax for a programming language that's supposed to be used by human programmers. Nevertheless, F3 provides the primary benefits other systems derive from XML and its supporting technologies, namely:
In addition, because F3 is a real object-oriented programmming language it allows you to factor your code the way we always have: namely be means of variables, subroutines, and class hierarchies.
Note that most if not all XML-based systems include some other embedded programming language, e.g. JavaScript or XPath or the EL of JSTL.
Finally, being a statically typed language F3 can provide IDE-support and compile-time error reporting equal in quality to what programmers are used to with Java. I'm not aware of any XML-based system that delivers a comparable user-experience for the programmer.
It may be surprising, however, to know that F3 was influenced by traditional web applications.
In a traditional web application you can "project" an HTML document from a set of Java beans by writing a "template". For example, in JSTL
<table>
<tr>
<th>
Description
</th>
<th>
Price
</th>
</tr>
<forEach var="item" items="${cart.items}">
<tr>
<td>
${item.description}
</td>
<td>
${item.price}
</td>
</tr>
</forEach>
</table>
Since, in traditional (non-AJAX) web-apps the page was regenerated every time, you could change your Java beans however you liked, and the page would appear to incrementally change without any additional programming (i.e, you didn't have to add "listeners" to the beans, respond to change events, and update the document yourself).
From my experience, the declarative syntax of the HTML template and the automatic regeneration of the pages, made writing web-based UI's way easier and faster than writing Swing programs.
In F3, the combination of declarative syntax, incremental evaluation, and list comprehensions brings that same ease of use to Swing and Java2D programming. For example, I can write a JTable in a manner similar to the one in the above example in F3 like this:
Table {<br>
columns: [TableColumn {text: "Description"}, TableColumn {text: "Price"}]<br>
cells: bind foreach (item in cart.items)<br>
[TableCell {text: bind "{item.description}"}, TableCell {text: bind "{item.price}"}]<br>
}As in the web-app example I can insert or delete items into/from the cart or modify the properties of an item and the table will automatically reflect my changes.
RSS Reader Demo
Having said all that, XML is still a reality and you may need to work with it in F3 programs. To enable that, we have an experimental add-on which plugs into F3 as an F3 class loader. This class loader reads XML Schema or WSDL documents and generates corresponding F3 classes (analagous to what JAX-B and JAX-RPC do for Java). The generated classes have methods to marshal and unmarshal XML documents and to invoke WSDL operations.
Below is an F3 program that uses this facility to create a simple RSS reader. It loads the RSS XML Schema and then reads the XML document at the URL you specify. This has the effect of populating corresponding F3 objects with the content of the XML document. Since these are first-class F3 objects, you can use F3 bindings on them as usual.
You can view the source code for this program by clicking its File->View Source menu.