views:

179

answers:

5

I just looked at one of those libraries that is of the naming schema "something-Linq" expecting to gain some more knowledge on how to construct expression trees in an elegant way - and was disappointed. Because all I could find were methods that extended IEnumerable - of course with "normal" C# code.

Now I have this question: Do non-expression extensions for IEnumerable really justify the name of the library to have "Linq" in it? Or is the author just jumping on a hype trying to get more downloads for his IEnumerable extension library and I was right in expecting IQueryable and expressions when seeing "Linq" in the name of the library?

Edit:

I would argue that there is a difference between Linq-to-... and something-Linq libraries. IMHO Linq-to-... are linq provider libraries, something-Linq are linq extensions. I think Linq provider libraries may choose if they expose IQueryable or IEnumerable in their results - linq extensions do not have that choice. As far as I am concerned they must be able to work with both kinds of provider libraries. That means for me that all linq extensions must provide both Queryable and Enumerable extensions.

Edit 2:

A very lively discussion took place between Jon and me in the comments of his answer. I volunteered to create a blogpost to hopefully clarify things: Mapping the uncharted waters of LINQ

Edit 3:

For anybody who is interested in the discussion - I really encourage you to go to my blog post. Skip the post itself because it is horrible - and go straight to the discussion and explanations by Jon.

+1  A: 

Short answer: Marketing gimmick

People uses the term "Linq-something" or "something-linq" as a marketing gimmick to give the customer/developer an idea what the library is. This saves the marketing (or documentation developer) time in explaining what the library does.

MrValdez
A: 

Yes, plenty of hype seems the name of the game

Also "construct expression trees in an elegant way" is an oxymoron

There are not many nice examples of good LINQ

The Linq to Sharepoint project is better than nothing

http://linqtosharepoint.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=8713

TFD
+4  A: 

LINQ doesn't imply expression trees to me. It implies data access in the general style of LINQ. LINQ to Objects doesn't have any expression trees in it, but is still definitely LINQ IMO.

LINQ to XML is a bit more specious - it's really just an XML API which exposes IEnumerable<T> in various ways, both as input and output. That means it works really well with LINQ to Objects, but it's not implementing any of the standard operators itself. However, you do typically use it with LINQ to Objects, and the result is "LINQ-like" code, so I guess it's not too bad.

I certainly have no problem with non-expression extensions being called LINQ-to-whatever - indeed, such a stance would be hypocritical given my MoreLINQ and Push LINQ projects.

To me there are two main questions:

  • Is the API about data access and processing?
  • Does it attempt to make the access/processing fluent, ideally (but not necessarily) conforming to the query expression pattern to enable the language features of VB9 and C#3 to help with readable code?
Jon Skeet
I don't know - System.Linq does have Queryable in it that relies heavily on Expression trees and which seems to be the one that is used when "from s in list where ..." gets compiled. Without expression trees the respective IQueryProvider could not do its magic transforming the that clause.
Tobias Hertkorn
That's used for LINQ providers which *need* to use expression trees (and which implement IQueryable, which isn't a necessity). If you use LINQ to Objects, however, that uses Enumerable instead of Queryable, and delegates instead of expression trees.
Jon Skeet
System.Linq also has Enumerable in it, which doesn't rely on Expression trees and implements the same operators. You should read Skeet's book!
Daniel Earwicker
@Earwicker I would argue that the Enumerable implementation (which I was aware of ;) ) is there for performance reasons. I suggest you look at EnumerableQuery. Oh, and having read a book is not an excuse to end an argument. ;)
Tobias Hertkorn
@Jon I was not talking about Linq-to-... "Provider" libraries. Those do have the authority to choose if they expose IQueryable or IEnumerable as their results. But libraries that claim to extend Linq imho must be able to seemlessly work with both kinds of provider libraries.
Tobias Hertkorn
@Tobias: I think you'd have to give a specific example before we could easily decide whether it's abusing the name "LINQ" or not. But I *do* think your apparent expectation that any library with the name "LINQ" in it will involve expression trees is unreasonable, and "Foo-LINQ" and (cont)
Jon Skeet
"LINQ-to-Foo" is not a distinction which is particularly well-defined. Are you disappointed that Parallel LINQ is really aimed at LINQ to Objects?
Jon Skeet
Aaah,too few characters. ;) PLINQ introduces IParallelEnumerable with a whole different game. And it is kinda unfortunate that LINQ is in the name. But I was really talking about libraries that imho, by using the Linq in their names, claim to extend the operation one can use on (cont)
Tobias Hertkorn
IQueryable but are I think somewhat lazy and just extend IEnumerable. Because then LINQ Provider aren't able understand those operations and optimize for them (ExpressionVisitor). Plus I'm kinda surprised that you claim there is no def for diff. -to- libraries provide a specialized IQueryProvider.
Tobias Hertkorn
I just don't see the implications you do: "By using the Linq in their names, claim to extend the operation one can use on IQueryable" - that's your inference, and I haven't come across anyone with the same inferences. You seem to understand LINQ to mean a very specific thing (cont)
Jon Skeet
- IQueryable and expression trees. I view it in a much broader way, and have no problem with Parallel LINQ, my own projects or similar things using the term "LINQ". Frankly *no* library is going to be able to extend what every provider can do, because they would have to know all about all providers.
Jon Skeet
Basically I think your expectations are unrealistic. Can you identify where those expectations come from? Why do you think that including LINQ in the name of a library means they're going to do cunning things with IQueryable?
Jon Skeet
These 300 chars are way too limiting. I'll do a blog post after work and hopefully clarify why I see a difference and do an example of a Linq extension that imho highlights the differences. Sorry that I could not clarify it enough. Will post the URL hopefully in the next 5-8 hours.
Tobias Hertkorn
Righto. I agree that discussion is kinda tricky in here :)
Jon Skeet
http://saftsack.fs.uni-bayreuth.de/~dun3/archives/mapping-the-unchartered-waters-of-linq/253.html rough, ugly, too long. Hope you excuse the format of the post and the code. It was a very quick shot from the hip. Comments are of course welcome. ;)
Tobias Hertkorn
Thanks - will comment later. You still seem to be focusing on IQueryable unnecessarily, IMO.
Jon Skeet
A: 

LINQ means something different to everyone (as is bound to happen when it is used to label everything):

  • A convenient way of accessing a database by expressing queries in an embedded DSL.
  • Language features that support analysing and transforming code at runtime.
  • Treating lists monadically using techniques inspired by lazy functional programming languages.
  • Treating anything monadically using... ditto.

By far the most useful one of these (to me) is the functional programming part, but I just call that functional programming instead to avoid confusion.

Daniel Earwicker
A: 

Everything to do with Linq is just "normal" C# code, mostly extensions of IEnumerable.

Edit: StackOverflow seems to want to hide that I actually said IEnumerable < T > above. It's not Linq-compatible!

amaca
Just put the term in backticks: `IEnumerable<T>`
Jon Skeet
I'm honoured! Thank you.
amaca