Hope you enjoyed the link to CSAML in our News section.
I think this is a very funny joke. Generally when a joke has to be explained, it is not considered funny, so I am not going to explain it but I’d like to discuss its significance because it relates very much to domain specific languages and to what is wrong with the current implementations.
It is important to realize that Charles Petzold’s examples are nearly real – they employ current techniques that people have to use for domain specific languages out of sheer necessity – but he applies them to the C# language where a highly usable but expensively developed syntax is already available. The contrast between the two - the luxurious C# and the cheap XML - is appalling and we find that funny in a kind of cruel “Upstairs, Downstairs” way – this was the British TV drama where the upper-class household upstairs was in contrast with the lower-class servants downstairs.
With projective systems you can have both great looks and inexpensive implementation. But there are two additional fine points: the source, no matter what is the notation, should not contain information that is computable from the rest. It should contain only things where the user is the only authority – that is the user’s intentions. For example, by this rule we could omit including the information that in the statement A=5/(B+27*C) the operand 27 is a multiplier, unlike in Petzold’s XML statements where an extra <Multiplication.Multiplier> tag was given. That information belongs in the definition of the multiplication, not in the source tree. Otherwise all we have is another hoop that the user and language transforming programs have to jump through.
The other point is that is that the awkwardness of XML and the lack of projections causes the language designers to intermittently fall back into text syntax.This happened, for example in the “Type” attribute of the joke: <Literal Type="{x:Type Int32}"> ; or in the XPath expressions of XSL in real life.
Here is how a similar example looks as an Intentional Tree:
Assign(A, Div(5, Plus(B, Mul(27, C)))
In this instance the Mul definition already knows that the first argument is the multiplier.
When we project it in the Intentional Editor the editable screen looks like this:
Of course many other editable projections are also possible, here are just a few more for fun:
Or:
The interesting point is that even the “not-projected” representation is not at all terrible; it looks a little like LISP. It is not intended for normal use by people; it is a projection of the binary internal representation. The main reason that it looks better than the joke example is that it does not include any information that should be in the schemas, or which is part of the general domain knowledge, in other words it is Intentional. Of course, if you want the real XML syntax, like Petzold joked about, it is just another projection where the schema information is included. And with that you can say you are a real XML programmer with all the scars!
See also http://homepages.inf.ed.ac.uk/wadler/language.pdf
Posted by: Pascal Costanza | April 07, 2006 at 04:41 AM
FWIW a very similar joke went around MS (at least the CLR group) on April 1, 1998 or 1999. I remember this clearly because I didn't get it and thus became the object of ridicule.
Posted by: Elijah Wong | June 19, 2006 at 12:12 PM
Well done Mr Simonyi,
I am gratified that you are working on this important area - I only stumbled across the idea of code generation about a year ago despite being a programmer for many years.
I am impressed by the idea of an "Intentional Tree", it reminds of a idea I toyed around with many years ago where I'd put program logic directly into a database rather than source code. I abandoned the notion when I did not see a fast buck in it.
I like the idea of editable projections - the way you presented them made them immediately clear. Multiple views of complex data can be used to get the user out of a rut, just as multiple views of a town (a map, talking to a local resident, driving around town) can help find a street you're looking for.
Posted by: Phil Bachmann | July 11, 2006 at 03:53 AM
You dirty rotten scammels! I just read the MIT TR article on meta-data with keen interest and my heart immediately lifted. I furiously started researching on the web, and eventually found Petzold's article on CSAML. Not knowing it was a joke, my heart sank, and I found myself muttering "Structural beauty, weep for joy--these guys still don't get it". Glad to see you do, and you have a sense of humor too!
Posted by: Andrew Brooman | January 17, 2007 at 11:33 AM