What are the similarities and differences between Groovy and LINQ?
Today twitting with a colleague, he said me that Groovy is like C# but without LINQ.
I don't know much about LINQ, but I answered him that Groovy has similarities to LINQ, for example, Groovy's class DataSet.
Can you tell me more about similarities / differences between Gro开发者_JAVA百科ovy and LINQ (C#)?
I wonder who told you that ;P
First, let me clarify my statement: Many of the things that I love about c# 4.0 are implemented on groovy, but groovy is already much more succinct.
There are other obvious differences like the dynamic/scripting nature of the groovy language and so forth.
now, linq is a step over closures, like a dsl inside c# to create closures in a query (sql) like sintax, with a pattern based on interfaces and a provider model behind to allow this closures to be translated to sql or to any kind of other representation.
In this respect, since groovy has closures and beautifully implemented, AND it has many dsl-building capabilities built in, it should be possible to make a linq-like feature.
The only similarity between C# and Groovy is their syntax. In other words, Groovy code looks fairly similar to C#. However, the true nature of the languages is very different. Groovy is more like Ruby in that it is dynamically typed and supports meta-programming. C# on the other hand is mostly statically typed.
As for similarities between LINQ and Groovy there are none really. Groovy is a general purpose language, whereas LINQ is a DSL for writing queries. A further difference is that C# and LINQ run on .Net whereas Groovy runs on the JVM.
精彩评论