The F3 Object Model

Chris Oliver who has developed the very neat Swing User Interface scripting language F3, describes the F3 object model in a recent blog entry of his. I mention it, because every time he explains it to me, I find the parallels with the RDF data model so amazingly striking that I can just attribute it to the fact that we are homing in on something absolutely fundamental. I keep thinking F3 has a great chance at being a major contender for a Semantic Web User Interface scripting language.

Here is what he says:

I wanted an easy way of creating Model/View GUI's. To that end I wanted a simple, object-oriented system. The informal conceptual basis for this I borrowed from Martin and Odell.

To summarize the important points (informally):
  • Classes correspond to the concepts we use to identify the common characteristics of the things around us and how they relate to each other.
  • Thus a class declares a set of potential relationships (links) between objects.
  • Once an object has been classified we can navigate those relationships to discover its properties, i.e. the other objects related to it.
  • In F3 these properties are called attributes.
  • In F3 functions are queries that navigate links or produce new objects in terms of existing ones, but do not modify the links of existing objects.
  • In F3 all change consists of adding new objects or of adding, removing, or replacing the links between existing objects.
  • In F3 Events are simply notifications of object instantiation or of "link addition", "link removal", or "link replacement"
  • In F3 operations in addition to performing queries can sequentially perform one or more such link modifications. Such modifications may be sequenced with conditional logic and by selection and iteration over query results.
  • The values of an object's attributes may be specified either through explicit assignment or by means of a bound query. In the latter case implicit modification of the attribute occurs whenever the inputs to the query expression change and produce a new result.
  • So when a change occurs one way to specify the "effect" is to define a bound query that expresses how other objects depend on it.
  • The other way to respond to change is by making further explicit modifications using triggers. A trigger is an operation that is performed whenever an insert, delete, or replace event which applies to it occurs.
As far as the syntax of F3, it's intended to be familiar to mainstream programmers whose primary language is derived from C (C++, Java, JavaScript, PHP, etc), but also includes features from query languages (OQL, XQuery, SQL).

To address each one of those points I have put together the table below. The left hand contains Chris' statments, and on the right I show how they map to semantic web ideas.

F3RDF and tools
Classes correspond to the concepts we use to identify the common characteristics of the things around us and how they relate to each other.Not too disimilar from how OWL defines a class: A class defines a group of individuals that belong together because they share some properties.
Once an object has been classified we can navigate those relationships to discover its properties, i.e. the other objects related to it. The object oriented way of navigating a graph of objects is indeed by starting from one object and finding how it relates to other objects by following the values of the (private, protected or public) fields of an object.
In F3 these properties are called attributes. In rdf the properties of an object are called either properties or relations. But "attribute" is just as good too for the purposes at hand. [1]
In F3 functions are queries that navigate links or produce new objects in terms of existing ones, but do not modify the links of existing objects. Functions are like small inferencing engines in some way. They find relations between objects by going from known relations to new ones, but they do not add any facts to the database.
In F3 all change consists of adding new objects or of adding, removing, or replacing the links between existing objects. RDF specs do not really deal with changes to the state of a database. That is outside the scope of the specification, but all programmatic tools such as Jena or Sesame have methods to help one do such things.
  • Those frameworks that keep very close to the basic rdf model such as Jena and Sesame give one ways of creating resources and setting their properties. This is how Jena adds a new relation:
    // some definitions
    String personURI    = "http://somewhere/JohnSmith";
    String givenName    = "John";
    String familyName   = "Smith";
    String fullName     = givenName + " " + familyName;
    
    // create an empty Model
    Model model = ModelFactory.createDefaultModel();
    
    // create the resource
    //   and add the properties cascading style
    Resource johnSmith
      = model.createResource(personURI)
             .addProperty(VCARD.FN, fullName)
             .addProperty(VCARD.N,
                          model.createResource()
                               .addProperty(VCARD.Given, givenName)
                               .addProperty(VCARD.Family, familyName));
    
    There are other methods to remove properties from a resource...
  • More Object oriented frameworks - that are usually build on the simpler frameworks above - such as Elmo or so(m)mer work like F3 in a more OO fashion. Elmo uses getters and setters to change object properties. So(m)mer like F3 just changes link relations by setting the fields directly. In F3 for example the following adds a new relation between a persons and their age:
    person.age = 23
    In so(m)mer this would be done the same way..
In F3 Events are simply notifications of object instantiation or of "link addition", "link removal", or "link replacement"Now this is the great originality of F3: in making the event mechanism transparent.

Tools such as Jena provide such a mechanism, as described in the Event handling docs.

Tools such as so(m)mer would have values change automatically if they were linked to an inferencing database. But none of them would generate the right kinds of events to control a swing gui, which is what F3 does in the background, saving one a huge amount of event handling code.

In F3 operations in addition to performing queries can sequentially perform one or more such link modifications. Such modifications may be sequenced with conditional logic and by selection and iteration over query results.
The values of an object's attributes may be specified either through explicit assignment or by means of a bound query. In the latter case implicit modification of the attribute occurs whenever the inputs to the query expression change and produce a new result.
So when a change occurs one way to specify the "effect" is to define a bound query that expresses how other objects depend on it.
The other way to respond to change is by making further explicit modifications using triggers. A trigger is an operation that is performed whenever an insert, delete, or replace event which applies to it occurs.

One thing that seems very clear from the above and having asked Chris Oliver about the implementation of F3, is that a triple database such as Jena could provide the base on which the F3 language is built. Jena has the key components: ways to add relations to a store and an event listening mechanism. F3 is the layer above that makes programming User Interfaces easy. Jena is of course heavy weight for most uses of F3 but perhaps not all - and perhaps one could have some interface to make that decision at run time. The up side looks just too good. With a little work F3 could be the Semantic Web UI scripting language.

[1] It occurs to me writing this that I would perhaps want to reserve the word attribute for links an object has to a literal, and the word "relation" for a link to another object... As far as the usage of the words goes in either F3 or rdf it makes no real difference.

Comments:

Hi Henry,

I agree; F3 is very cool. Thanks for the lead.

I would be fascinated to hear more about your statement that, "I keep thinking F3 has a great chance at being a major contender for a Semantic Web User Interface scripting language." I was trying to see where the links with Web UIs might occur.

Also, do you think this might be the answer to Yegge's hilarious challenge for "Scheme on Skis" (http://steve-yegge.blogspot.com/2006/09/bloggers-block-3-dreaming-in-browser.html)?

Thanks, Mike

Posted by Mike Bergman on February 06, 2007 at 01:45 PM CET #

Thanks for the "Scheme on skis article". It's a little long, but it has helped me understand why some people may dislike rdf. The javascript interaction it describes there with rdf is indeed really ugly. What is needed is some way to map javascript objects to rdf ontologies, a little in the way I do with so(m)mer, so that you can write a class like AtomEntry using annotations, and use it like a normal java object:
AtomEntry e1 = new AtomEntry(ENTRY1_ID, t1);
Content c = new Content(E1_SUMMARY);
e1.setSummary(c);
Content title = new Content(E1_TITLE);
e1.setTitle(title);
mapper1.addObject(e1);
Don't forget that rdf in mozilla was perhaps the first implementation of rdf around and that it has not much improved.

Concerning your other point: think iTunes. The author of the above article is wrong. Not all applications need to be in a browser. In fact my guess is that with time all applications will become web enabled. That is what the Semantic Address Book is partly about to show.

Posted by Henry Story on February 06, 2007 at 03:35 PM CET #

Post a Comment:
Comments are closed for this entry.
About

bblfish

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today