Eric Meijer's Confessions

Is Scala the FOSS Linq?

By Rick Jelliffe
April 20, 2010 | Comments: 2


I have been looking at making parsers in Scala, to figure out a good way to get an expression validator for XPath2. Followed some links and arrived at a killer 2006 ICFP OOPSLA '07 paper by Eric Meijer Confessions of a Used Programming Language Salesman which is subtitled Getting the Masses Hooked on Haskell though it ends up being mostly about the XML support in Microsoft's research and product languages Cω, Linq, C# and Visual Basic 9.

Here are some of the quotes that stood out:

...programmers constantly need to juggle three very disparate data models: Relations in the data tier + Objects in the business tier + and XML in the presentation tier = ROX.

Not only is each data model fundamentally different, but each comes strongly coupled with its own programming language, typically SQL for relational data, an imperative language such as Java, C], or Visual Basic for objects, and XQuery or XSLT for XML. The deep impedance mismatch between the three inhabitants of the ROX triangle is the reason that many programmers in the real world are pulling their hair out on a daily basis.

ROX is a useful idea. (Some impedance mismatch can be avoided merely by having XML at the data tier, XML manipulated by objects (not turned into them using schemas), and XML at the presentation tier. Not always possible, but common in publishing.)

2.1.1 The Sucking Black Hole of XSD

The main problem of XSD is not that it gratuitously uses XML as its concrete syntax, but the fact that it is completely overengineered for the problem it attempts to solve. The most confusing aspect of XSD is the notion of complexType. ...

We could go on for pages talking about the subtleties of mapping XSD to objects, but we cut it short by observing that any attempt that does not uniformly map elements to types is fundamentally flawed because XML values are node-labeled trees, while objects are edge-labeled graphs.

I think Schematron validates edges, in this sense.

I became convinced that deep embedding is the best way to deal with XML in a language, with an optional and layered type-system on top. This led me to the realization that Visual Basic was the ideal language for the road ahead because it is the only widespread language that allows static typing where possible and dynamic typing where necessary.

Meijer's VB description seems pretty much what Scala does: embed XML as XML objects without farting around with schemas (though Meijers idea seems to be to allows some kind of late binding of types to objects: dynamic typing):

Unlike Cω, we do not assume any schema information. Instead we will optionally layer XSD information on top of the CLR type-system to guide Intellisense in the IDE for XML literal construction and axis members. However, this type information has no impact on the runtime behavior of the program.
4.4 Type-System Extensions

One of the nice things about the relational model is the fact that relationships are external. That is, children point to the parents (foreign key → primary key relationship) as opposed to from the parent to the child. As a result, it becomes possible to create explicit relationships [13] between types after the fact, without modifying the participating types. This is important when we want to relate data from different sources.

I never read or heard a justification for Linq before: the idea of unifying ROX processing seems pretty cluey. It will be interesting whether Scala, which shares so much of the functional programming influence, can be considered the FOSS communities answer to MS Linq.

You might also be interested in:


Though the paper may have been originally intended for ICFP '06, it was actually published in OOPSLA '07; the ACM publication record is here.

Peter: Thanks for that. I have corrected it. North Americans are so lucky to have a conference like OOPSLA!

News Topics

Recommended for You

Got a Question?