Tomorrow, I'll be giving a talk at the Microsoft TechDays 2008 conference. This is the main developer-related Microsoft event here in France. There will be about 280 technical sessions and I’ve heard the organizers expect 15,000 attendees! The subject of my talk is LINQ, a set of new technologies added by Microsoft to languages such as C# and Visual Basic. LINQ aims at radically simplifying the way object-oriented languages deal with objects and other information models such as relational databases or XML infosets.
I've been hooked on LINQ since the beginning, when its ideas started to be experimented in the context of the Cω research project. My buddy Fabrice Marguerie, with whom I'll be giving the talk, describes LINQ in his new book, LINQ in Action:
LINQ stands for Language Integrated Query. In a nutshell, it makes query operations like SQL statements into first-class citizens in .NET languages like C# and VB. LINQ offers built-in support for querying in-memory object collections such as arrays or lists, XML, DataSets, and relational databases. But LINQ is extensible and can be used to query various data sources [...]
In addition to offering novel approaches to deal with data, LINQ represents a shift toward declarative and functional programming. When people ask me for reasons to learn LINQ, I tell them that they should learn it in order to be able to use it with XML, relational data, or in-memory collections, but above all to be able to start using declarative programming, deferred execution, and lambda expressions.
While LINQ and OOPAL (the array programming model adopted by F-Script) are based on very different principles, they share a common goal: providing a higher-level programming model that allows for more expressive and powerful language constructs. We can illustrate this with the following example, comparing some typical code in a classic object-oriented language (here, Java) with the code in C# with LINQ and F-Script with OOPAL.
In this example we deal with the object model of an airplane company:

Say we have a collection of flight objects named flights. Starting there, we want to get the names of the pilots in charge of a flight to Paris on a B747 airplane. And we want them sorted by salary in increasing order.
Java
TreeSet<Pilot> pilots = new TreeSet<Pilot>(new Comparator()
{
public int compare(Object o1, Object o2)
{
if (((Pilot)o1).salary() < ((Pilot)o2).salary())
return -1;
else if (((Pilot)o1).salary() == ((Pilot)o2).salary())
return 0;
else
return 1;
}
});
for (flight : flights)
{
if (flight.arrivalLocation().equals("PARIS") && flight.airplane().model.equals("B747"))
{
pilots.add(flight.pilot());
}
}
ArrayList<String> result = new ArrayList<String>();
for (pilot : pilots)
{
result.add(pilot.name());
}
C# (with LINQ)
var pilots = (from flight in flights
where flight.arrivalLocation == "Paris" && flight.airplane.model == "B747"
select flight.pilot).Distinct();
var result = from pilot in pilots
orderby pilot.salary
select pilot.name;
F-Script (with OOPAL)
pilots := (flights at:flights arrivalLocation = 'PARIS' & (flights airplane model = 'B747')) pilot distinct.
result := pilots name at:pilots salary sort.
The three programs manipulate plain old standard objects (respectively Java, .NET and Cocoa objects). However, the programming models on which they are based differ and, as you can see, the C# and F-Script versions are shorter and more expressive.
If you are around and want to know more about LINQ, you can come to my session!

Hi,
Thanks for the great post on LINQ and OOPAL. I thought you’d be interested in some free hands-on developer training on LINQ to SQL. It also covers other .NET 3.5 topics:
* New Features in C# 3.0
* New Features in VB 9.0
* LINQ to SQL
You can check it out here:
http://www.innerworkings.com/promotions/75d4bd51-4bf1-4d8a-8c47-73135e44837a/visual-studio-2008-promotion
Cheers,
Brian Finnerty
http://blogs.innerworkings.com/brian-finnerty
The Groovy version is also pretty interesting and concise, and it follows a similar approach to Link and F-Script:
def pilots = flights.findAll { it.arrivalLocation == ‘Paris’ && it.airplane.model == ‘B747′ }.collect { it.pilot }.unique()
def result = pilots.sort { it.salary }.collect { it.name }
The python version is also similar.
pilots = sorted([flight.pilot for flight in flights
if flight.arrivalLocation == "Paris" and flight.airplane.model == "B747"],
key=lambda p: p.salary)
result = [pilot.name for pilot in pilots]
orderby syntax in list comprehensions (instead of sorted) would be nice but it has been ruled out by the BDL unfortunately.
[...] de Cocoa sobre Objective-C. El titulo de este post tiene relación en un artículo que lei en Fun Script (Blog dedicado a F-Script) en donde queda de manifiesta la simplicidad de la programación y cuando [...]