A Declarative Approach to Services

Steven Pemberton, CWI and W3C, Amsterdam

An example

Instant translate with XForms

The Cray

In the 1980's when PCs were new, the most powerful computers were Crays, huge machines with extensive cooling.

And people used to say "One day we will all have a Cray on our desk".


So do we have a Cray on our desk now?


So do we have a Cray on our desk now?

Sure: in fact current workstations are about 120 Craysworth.


So do we have a Cray on our desk now?

Sure: in fact current workstations are about 120 Craysworth.

Even my previous mobile phone was 35 Craysworth...

We live in an exponential world

To demonstrate Moore's Law

Take a piece of paper, divide it in two, and write this year's date in one half:



Now divide the other half in two vertically, and write the date 18 months ago in one half:



Now divide the remaining space in half, and write the date 18 months earlier (or in other words 3 years ago) in one half:



Repeat until your pen is thicker than the space you have to divide in two:



This demonstrates that your current computer is more powerful than all other computers you have had put together (and the original Macintosh (1984) had a tiny amount of power.)

So how are we using all that extra power?


Mostly for pixel pushing.

Most computers spend most of their active life idle.

Our Idle Computers

Twice as idle

Why aren't we using the extra power to make people's (our!) lives better?

The cost of producing applications

According to the DoD, 90% of the cost of software is debugging.

According to Fred Brookes, in his classic book The Mythical Man Month, the number of bugs increases quadratically according to code size: L1.5.

In other words, a program that is 10 times longer is 32 times harder to write.

Or put another way: a program that is 10 times smaller needs only 3% of the effort.

Constructing Applications

The problem is, in comparison to web sites, no one writes applications except programmers.

With an interesting exception: spreadsheets.

Mostly because they use a declarative programming model.

The nice part about declarative programming is that the computer takes care of all the boring fiddly detail.


XForms is a recent technology from W3C.

As its name suggests, it comes from an analysis of HTML Forms, and the needs of the community for Forms support.

However, because of the generality of the resulting design, it turns out to be useful for a lot more than just Forms.

XForms: the essence

XForms uses essentially a Model-View-Controller approach, so that the memory model is completely separated from the input/output.MVC

The model specifies the values being collected (the instance), and their related logic:

Input/output controls then bind to values in the instance

Intent-based controls

The input controls, rather than expressing how they should look (radio buttons, menu, etc), express their intent (for instance: "this control selects one value from a list").

You then use styling to say how they should be represented, possibly with different styling for different devices (as a menu on a small screen, as radio buttons on a large screen).

Three possible representations of the control "select one from a list":

Colour: red green blue

The instance

The place where values are stored is called an 'instance' (there can be several of them). Each is an XML document:

   <data xmlns="">

It has a spreadsheet-like computation model:

<bind nodeset="bits"
      calculate="../height * ../width *

External instances

An instance can be initialised by anything addressable with a URI, which includes local files, but also anything over the net:

<instance src="http://www.example.com/values"/>


The values in an instance can be submitted over the net:

<submit action="http://www.example.com" ... />

but a nice feature is that the result of the submission can:

XForms for services

So we have:

Everything we need for service-oriented computing.


Of course SOAP messages are also just XML instances, so XForms has everything you need to create, send, receive and unpack SOAP envelopes.

An Example: Flickr

Flickr (use Firefox)

Flickr (IE with plugin)

Case study: Cordys

Cordys are building a system to deal with legacy systems.

Essentially they build a wrapper around each legacy machine that makes the machine talk SOAP.

Then they connect all machines with an XML data bus carrying the SOAP messages.

All messages contain all the transaction details: so the system is stateless (and therefore scalable).

Originally they used Ajax to provide the user interface, but started losing programmers to nervous breakdowns: Javascript has no engineering support.

They now use XForms.

Google maps

Google maps

More than 200K of Javascript

Google maps in XForms

Google maps in XForms

Google maps as Declarative Application

Although the example shown above is not quite complete, it does more than Google maps does and yet it is only 25Kbytes of code (instead of the 200+K of Javascript), and was written by one person.

Remember, empirically, a program that is an order of magnitude smaller needs only 3% of the effort to build.

Another data point: big machines with complicated interfaces

A company makes BIG machines (walk in): user interface needs 5 years, 30 people

This became: 1 year, 10 people with XForms

10 person years instead of 150 person years.

Implementations of XForms

Different types of implementation:

Many big players have done implementations, e.g.

Mobile implementation



The advantages of the XForms approach include:

More on XForms

XForms for HTML Authors Part 1, Part 2

XForms home page

XForms Flickr tutorial