Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How unique is LINQ?

This is a question about LINQ the .NET language feature, not LINQ to SQL.

I find that the ability to query almost any in memory collection in such a consistent and declarative way is one of the best language features I've ever come across.

I find it extremely useful, and I love the clean abstraction it provides. LINQ can even be used to query Strings, indeed its extremely flexible.

My questions are:

  1. Is this idea of "Language Integrated Queries" new? and if not, what other languages implement a similar feature
  2. How do other implementations compare to Microsoft's?
  3. This is a little subjective, but how important do others feel LINQ, as an idea, is?

cheers

like image 410
andy Avatar asked Jun 05 '09 01:06

andy


2 Answers

The idea of language integerated query is not new, the way MS puts it is unique and new. It is affected by Haskell and SQL syntax, Haskell had the idea of enumerators and lazy evaluation which is the core underline principle in implementing LINQ, in fact LINQ is just a syntactic sugar.

I feel link is a great bridge between reasoning about your programs and data in an abstract and clean way.

like image 195
mfawzymkh Avatar answered Oct 20 '22 16:10

mfawzymkh


Speaking as a querying of in memory collections, no this is not a unique feature. Take for instance F#'s pipe forward operator. It allows you to write very similar style operations as you would a linq query.

Take for instance the following code which extracts digits from a string and sums them

"foobar42".ToCharArray() 
  |> Seq.filter System.Char.IsDigit 
  |> Seq.map (fun x -> x.ToString() ) 
  |> Seq.map System.Int32.Parse 
  |> Seq.sum
like image 32
JaredPar Avatar answered Oct 20 '22 16:10

JaredPar