On Sunday, 15 March 2015 at 00:56:24 UTC, Ellery Newcomer wrote:
On Saturday, 14 March 2015 at 23:57:33 UTC, weaselcat wrote:
On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote:
And C# has LINQ, which when combined with the last point is fricken awesome.

what does LINQ offer that UFCS-style functional programming does not?

LINQ basically is a UFCS-style api. AST reflection is what makes it nice.

consider:

X.Where(x => x.Members.Count() == x.Admins.Count())

straightforward in both D and C# when X is an array or container type.

When X is a table in a database, things get tricky for D.

C# can interpret the lambda as an Expression<Func> (an AST type), so the implementation of X can reflect over the body of the lambda and use it to generate the appropriate SQL. ORMs such as entity framework and nhibernate do this now.

Even if we can't get the lambdas as syntax tress, the fact that we can send whatever types we want to the delegates and overload operators and stuff means we can still convert the lambdas into SQL.

Here is a very crude, very basic example: http://dpaste.dzfl.pl/94d851d7ca63. An enterprise implementation will be much bigger and much more complicated - but so is the C# implementation.

At any rate, I really don't like what C# did with LINQ-to-SQL. The whole special-syntax to functional-style to syntax-tree to SQL is too overcomplicated - a simply lisp-style macro system(like what they have in Scala or Rust) could have done the trick in a simpler and faster way.

Reply via email to