Compiler Dev Lab – LINQ

Even though I haven’t finished my ETech postings, I’m already onto another event. This week, thanks to an invite from Michael Lehman, I’m sitting in on a Compiler Lab discussing implementing other languages for CLR. The first day was about LINQ. Much of the info is rehashed from PDC or the docs up on MSDN. However, I have learned a few new things.

  • One of the standard features of LINQ is Extension Methods. That enables you to declare a static method like “static void Foo(this string source)” and then use it like “stringvar.Foo()”. Apparently, they are considering adding other types of extension members including properties and fields. The idea of extension fields is somewhat scary but powerful.
  • LINQ uses something Anders called deferred query execution. The query isn’t executed until the values are asked for (typically by calling foreach on the query). That means you can compose queries to your hearts content with no perf impact until you actually invoke the query.
  • Query Comprehensions in C# and VB is a pattern implementation in a similar vein to foreach. Foreach is relatively simple shorthand for iterating through an collection by calling IEnumerator.MoveNext until it returns false. While LINQ enables arbitrary composition of queries, there is obvious gravitational pull towards the SELECT / FROM / WHERE / ORDER BY / GROUP BY approach favored by SQL. So if you build your own query operator, you can include it in a LINQ query, but C# and VB won’t be able to include it in the Query Comprehension syntax. Probably not a big deal, given the breadth of standard query operators as well as the deferred query execution, but it’s good to understand how the abstraction works.
  • I want to know more about how DLinq is implemented. I’ve been refining my thinking about data since working with Ning’s content store and I’m convinced of the need for a simplified datastore. SQL is designed for significantly complex database schemas, which means a significantly complex development environment.
  • I’m looking much more closely at VB, given the new features in VB 9.0. Not only the LINQ stuff from C# like type inference, extension methods and anonymous types but also VB specific stuff like XML Literals and Duck Typing. Combined with VB’s existing support for late binding, there are compelling features to make VB attractive over C#.
  • I’ve been hanging out with Brian Beckman. He’s a hoot.
  • I think I need to take a deeper look at F#.

Comments:

What, no mention of hanging out with me today at the F# thing? -))
Well, it's not like us DLinq devs are exactly hiding.. ;)