| In the case of Python and Java, I think it's because generator expressions and Streams, respectively, accomplish much the same thing. Honestly, if you've seen what LINQ compiles to, it looks an awful lot like a Java 8 Stream. Using Wikipedia's example of LINQ translation (https://en.wikipedia.org/wiki/Language_Integrated_Query#Lang...): Written LINQ is: var results = from c in SomeCollection
where c.SomeProperty < 10
select new {c.SomeProperty, c.OtherProperty};
It compiles to: var results =
SomeCollection
.Where(c => c.SomeProperty < 10)
.Select(c => new {c.SomeProperty, c.OtherProperty});
And in Java 8: Stream<> results = someCollection.stream()
.filter(c -> c.getSomeProperty() < 10)
.map(c -> new AbstractMap.SimpleEntry<>(c.getSomeProperty(), c.getOtherProperty()));
(of course, iterating over them is different; you just use a for loop in C#, but in Java you have to either use .forEach() or .collect() to a collection and then for over that)I think Streams have more LINQ in them than most people think. Disclaimer: it's been about a year since I've written Java 8, and this is off the top of my head (and the last time I used it, my employer's codebase had a class for pairs that was better than just SimpleEntry), so the code could be wrong. Edit: and just for completeness... the same in Python generator expressions: results = ((c.some_property, c.other_property)
for c in some_collection
if c.some_property < 10)
Not very LINQ-like, but it serves the same purpose. |