Lambda the Ultimate

inactiveTopic Programming with Rectangles, Triangles, and Circles
started 10/15/2003; 2:38:24 PM - last post 10/17/2003; 1:48:16 PM
Ehud Lamm - Programming with Rectangles, Triangles, and Circles  blueArrow
10/15/2003; 2:38:24 PM (reads: 7032, responses: 14)
Programming with Rectangles, Triangles, and Circles
This paper proposes extending popular object-oriented programming languages such as C#, VB or Java with native support for XML. In our approach XML documents or document fragments become first class citizens. This means that XML values can be constructed, loaded, passed, transformed and updated in a type-safe manner. The type system extensions, however, are not based on XML Schemas. We show that XSDs and the XML data model do not fit well with the class-based nominal type system and object graph representation of our target languages. Instead we propose to extend the C# type system with new structural types that model XSD sequences, choices, and all-groups. We also propose a number of extensions to the language itself that incorporate a simple but expressive query language that is influenced by XPath and SQL. We demonstrate our language and type system by translating a selection of the XQuery use cases.

Another one from Erik Meijer...

I think this is the first time the name Xen is mentioned here on LtU. Xen, is a hypothetical extension of C# with first-class XML support. The authors give details of the language and its type system, as well as a number of examples to illustrate its elegance and expressive power.

We are fond of discussing APIs vs. programming languages, so the following rule of thumb from the paper should be of interest:

we suggest that should one see an API that uses strings as a representation for some other important artifact, then this API requires re-designing and/or consideration for promotion to the programming language.


Posted to xml by Ehud Lamm on 10/15/03; 2:41:10 PM

Daniel Yokomiso - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/15/2003; 3:10:59 PM (reads: 799, responses: 1)
The "html" link works only on IE. Both Mozilla 1.4 and Opera 6.03 fail to render the page. Is this a future's glimpse of Microsoft hosted papers?
I'll talk about the paper later, because my preferred way of reading html papers (using Plucker) won't work this time

Ehud Lamm - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/15/2003; 4:18:38 PM (reads: 784, responses: 0)
Xen etc. also appear, of course, in this paper.

Ehud Lamm - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/15/2003; 4:22:44 PM (reads: 794, responses: 0)
Well, you can read the XML source of the paper, if you like.

Michael R. Head - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/15/2003; 7:57:02 PM (reads: 768, responses: 0)
Or you can "wget http://www.research.microsoft.com/~emeijer/Papers/XML2003/XML%202003.xml", "wget http://www.research.microsoft.com/~emeijer/Papers/XML2003/gca2html.xslt", and "xsltproc gca2html.xslt XML%202003.xml" to get the mozilla-readable HTML.

Martin Bravenboer - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/15/2003; 9:47:59 PM (reads: 762, responses: 0)
I've uploaded the html version.

Ehud Lamm - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 12:29:26 AM (reads: 727, responses: 0)
Regarding our ongoing discussion of OO, consider this example from the paper:

book* AWbooks = bib.book[it.publisher == "Addison-Wesley" && it.year > 1991];

[...] represent a filtering expression.

Obviosuly, what you want inside the [..] is a lambda expression (i.e., an annonymous function). But what would its signature be like? So we provide a magic variable it. Not very sexy.

I wonder what happens when these expressions are nested...

Ehud Lamm - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 2:18:28 AM (reads: 704, responses: 0)
Is Xen implemented, or are all these ideas still just er.. ideas?

Isaac Gouy - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 8:55:34 AM (reads: 641, responses: 1)
Xen etc. also appear, of course, in this paper.
And received more attention here on LtU.

Ehud Lamm - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 10:14:28 AM (reads: 628, responses: 0)
I knew I coudl count on you to find the link. Thanks.

Isaac Gouy - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 10:25:55 AM (reads: 619, responses: 0)
But what would its signature be like?
another opportunity to get out of my depth... have pity
   book* AWbooks = bib.books[it.publisher == "Addison-Wesley" && it.year > 1991]; 

   <T> T -> boolean
but linked to the type of the collection elements
   <Collection C, T> C<T> and T->boolean

My assumption was that we would want the magic variable for method calls (rather than for the field access shown). Maybe they just think this sugaring will be more acceptable in a mainstream language:

   bib.books[it.publisher == "Addison-Wesley" && it.year > 1991]; 
instead of something like this
   bib.books.filter(book it => it.publisher == "Addison-Wesley" && it.year > 1991); 

Isaac Gouy - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 10:43:18 AM (reads: 613, responses: 0)
The concept of methods that return multiple times is also available in XQuery, which (confusingly) uses the return keyword instead of yield. It is also supported by several other programming languages including Icon, Clu, and Python, and will be in the next version of C#.
Oh - guess I missed that announcement.

Patrick Logan - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 10:51:04 AM (reads: 608, responses: 0)
But what would its signature be like?

Ideally the entire square bracket notation would be have lazy semantics and the implementation would have access to the internal representation of the collection of books in order to perform an efficient query plan.

Right?

Who's to say how big this database is, or if it all fits in RAM?

Sjoerd Visscher - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/16/2003; 2:48:51 PM (reads: 578, responses: 0)
Who's to say how big this database is, or if it all fits in RAM?

Erik calls filterable objects "streams", so it's not unthinkable that it will be possible to retrieve one item at a time from the database.

About the syntax: I'm working on similar syntax for Loell 2, but with {} instead of []. ([] is was already occupied) The code between {} is run as a method on each item, so the shortest syntax would be:

bib.books{.publisher == "Addison-Wesley"; .year > 1991}

This is actually a lambda expression, where the argument defaults to me. If you want to give it a name, you can do that too:

bib.books{|book| book.publisher == "Addison-Wesley"; book.year > 1991}

The only thing the paper mentions about handling streams is this filtering and apply-to-all. In Loell all operations on streams are applied element wise, f.e.:

aStreamOfNumbers + 1

would return a new stream with each number in it increased by one. The result effect is that when you want to perform operations on the data as a whole, you'll have to collect the elements in a collection first, f.e.:

GetTotalByZip = {|books,zip| [>books{.zip = zip}] sum {.price * .quantity } }

Dan Shappir - Re: Programming with Rectangles, Triangles, and Circles  blueArrow
10/17/2003; 1:48:16 PM (reads: 479, responses: 0)
I wonder how this compares to E4X.

As I pointed out in that discussion, I don't get the need to extend the PL with domain-specific extensions where perfectly good general purpose facilities are already available. Instead of implementing an XML-only extension to C#, they could have built on the existing deletagte functionality that is already available. All they need to do is provide a bit of syntactic sugar for it.