Although Silverlight is the star of MIX 07, this is a big Microsoft developer show and there are all kinds of things going on. My favorite session from yesterday was Anders Hejlsberg’s mega-demonstration of LINQ. It’s come a long way since I first saw it at the 2005 PDC, and since my mid-2006 screencast with Anders. All along, he’s been very patiently and persistently reinventing the relationship between programming languages and data.
You have to be a certain kind of person to enjoy watching Anders run LINQ through its paces, Intellisensing his way through the construction of C# queries against object, SQL and XML data, but I am that kind of person, and I find it utterly hypnotic. In this particular demo, he spent a lot of time creating snippets of C# code to generate SQL queries, and peeking under the covers at the SQL that gets generated. There were two key takeway points. First, obviously, that some dodgy SQL effects become available to average developers who might otherwise not be able to achieve them. But second, and more subtly, that even the simplified query syntax in the C# code can be made simpler. The tool-generated code that represents SQL tables, for example, can now express relationships among tables directly. Given a table of Products and a table of Categories, you can eliminate the join syntax from a LINQ query and treat Categories as a property of Products. The bottom line is not only writing (and reading) less SQL code, but also less C# code.
There is, however, a connection between Silverlight and LINQ. As I mentioned yesterday, LINQ for in-memory objects is part of Silverlight. I haven’t had a chance to try this yet, but I do have a good example of the kinds of things I’d want to use it for.
The first version of my InfoWorld metadata explorer was actually a client-side application — still available here (for Firefox only) — that pulled a bunch of metadata into local memory and used XPath queries and JavaScript list filtering to produce its effects.
The server-based version uses Python to accomplish the same effects. With Silverlight it should now be possible to move that Python version back to the client, where it would probably run faster than the JavaScript version. But what I’m really interested to see is whether I can use LINQ in Silverlight to simplify the gnarly XPath and list-filtering logic in order to make the thing easier to understand and maintain.
To take this a step further, recall my earlier observations about Greasemonkey and Silverlight. A lot of the time, when we use the web, we’re effectively performing joins among data sources. You visit one site to look up some data, then you grab some of it and plug it into another site. If you’re lucky, somebody will have built a mashup, on a third site, to facilitate that join. But what if your browser had the data manipulation chops to help you do that mashup directly? I’m hoping that technologies like Silverlight and LINQ will enable things like that to happen.
I’ll be interested in your analysis of the use of LINQ in the DLR in the “Jim and John Talk” demo (see http://oakleafblog.blogspot.com/2007/04/stealth-dynamic-languages-presentation.html)
–rj
Hi Jon,
I was looking for a video of Anders’ presentation – do you know if one is available, or will be available, somewhere?
NOTE: You misspelled “Hejlsberg” (and I, for once, spelled “misspelled” correctly on the first try).
Thanks,
Ed
I think your last point would eventually use something like Astoria http://astoria.mslivelabs.com/.
Astoria exposes server-side Entity Data Models over the Web, but AFAIK it’s not useable for creating generic mashups by joining arbitrary data on the web. The EDM does have a LINQ story, but as far as I know that’s not exposed via Astoria. LINQ can take multiple data sources — including the XML/RDF returned by Astoria — and join them on the client, which with Silverlight can either be a traditional Windows app or a “rich internet/interactive application” running in IE, Safari, or Firefox (and presumably more platforms someday).
More generally, don’t try to find more order here than actually exists. This is evolution in action happening all over the company, not intelligent design by Gates, Ozzie, or any other supreme being :-) Silverlight, LINQ, EDM/Astoria, a bunch of stuff in incubation, and probably some unannounced products are all swimming around in the primordial soup right now. Watch what helps real customers survive and prosper, and how they cross-fertilize each other if you want to predict which of these technologies will rule in the long run.
>But second, and more subtly, that even the simplified query syntax in the C# code can be made simpler. The tool-generated code that represents SQL tables, for example, can now express relationships among tables directly. Given a table of Products and a table of Categories, you can eliminate the join syntax from a LINQ query and treat Categories as a property of Products. The bottom line is not only writing (and reading) less SQL code, but also less C# code. he was trying to handle this:
LinqQuery query = from call in context.GetObjectSearcher()
join user in context.GetObjectSearcher() on call.UserID equals user.ID
where user.Name.Contains(“Christian”)
orderby call.ID
select call;
When when I said why not just handle this:
LinqQuery query = from call in context.GetObjectSearcher()
where call.User.Name.Contains(“Christian”)
orderby call.ID
select call;
This is what people don’t get about conceptual models… they simplify programming scenarios immensely.
Okay… so I stuffed that comment up… let me try again.
– But second, and more subtly, that even the simplified query syntax in the C# code can be made simpler. The tool-generated code that represents SQL tables, for example, can now express relationships among tables directly. Given a table of Products and a table of Categories, you can eliminate the join syntax from a LINQ query and treat Categories as a property of Products. –
I was talking to a friend (the author of an OR/M called Opf3) about this very issue, he was trying to implement IQueryable[T] and was having trouble with this:
LinqQuery query = from call in context.GetObjectSearcher()
join user in context.GetObjectSearcher() on call.UserID equals user.ID
where user.Name.Contains(”Christian”)
orderby call.ID
select call;
When I said why not just handle this:
LinqQuery query = from call in context.GetObjectSearcher()
where call.User.Name.Contains(”Christian”)
orderby call.ID
select call;
Which is of course a lot simplier, but relies on a conceptual model, overlaid on top of the data model. This is what people don’t get about conceptual models… they simplify programming scenarios immensely.
Jon: Please delete the other comment!
The presentation is now online at http://sessions.visitmix.com/silverlight/v1/videos/DEV04.wmv
Maybe OT, but did anyone mention security yet in the Silverlight context?
I guess since the great MS push two or so years back it will be either:
1) thoroughly inherent in every part of the infrastructure
2) about to be bolted on as an after thought.
Any afterthought?
What I always like about any of Anders’ talks is that he simplifies everything so well (and indeed, linq is nothing but simplification). For example, he demonstrates the skip and take ORM methods, then shows the query that is generated to make them possible; “row number over yakity yakity…”. The query in SQL Server 2005 is fairly complex; the methods are simple.
It seems to inspire confidence when someone as bright as Anders raises the level of abstraction. I get the feeling I won’t ever find myself having to dig into the abstraction because it will be done right.
You really make it seem so uncomplicated with your presentation but I find this topic to be really something which I think I would in no way understand. It seems too complicated and also extremely broad for me. I am looking forward for your next post, I will try to get the hang of it!
Considerably, the post is actually the freshest on that worthy topic. I concur with your conclusions and will eagerly look forward to your incoming updates. Saying thanks will certainly not simply just be sufficient, for the fantasti c lucidity in your writing. I will certainly promptly grab your rss feed to stay informed of any kind of updates. Pleasant work and also much success in your business efforts!