LINQ presentation

Anders Hejlsberg, creator of Turbo Pascal and C#, delivered a great presentation on LINQ on Tuesday. This was actually my first contact with LINQ (which stands for Language INtegrated Query), but it makes me envy the C# and VB.NET programmers, because these are the only two languages that support it. LINQ defines a set of general-purpose standard query operators that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET-based programming language. It basically introduces SQL-like queries as first citizens of C# and VB.NET.

 Andres Hejlsberg at the MVP Global Summit 2007

A very simple sample provided by Don Box and Anders Hejlsberg in their article “The LINQ Project” at MSDN (http://msdn2.microsoft.com/en-us/library/aa479865.aspx) shows a query on objects in C#:

using System;
using System.Query;
using System.Collections.Generic;

class app {
  static void Main() {
    string[] names = { "Burke", "Connor", "Frank", 
                       "Everett", "Albert", "George", 
                       "Harris", "David" };

    IEnumerable expr = from s in names 
                               where s.Length == 5
                               orderby s
                               select s.ToUpper();

    foreach (string item in expr)
      Console.WriteLine(item);
  }
}

The output of the program being:

BURKE
FRANK
DAVID

Procedural languages, that express both what to do and how to do, have reached a point where there is nothing more to enhance. Removing the "how" part of the equation seems to be the next direction in the development of such languages. One of these cases is represented by the LINQ project, which simply makes C# and VB.NET more powerful.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.