3 ms·
Just because they can translate doesn't mean it's good. If you check out this example: https://github.com/mythz/java-linq-examples/blob/master/README.md#linq19-
by inglor 11y ago
Just because they can translate doesn't mean it's good. If you check out this example: https://github.com/mythz/java-linq-examples/blob/master/README.md#linq19-selectmany---indexed https://github.com/mythz/java-linq-examples/blob/master/READ... it converts 6 lines of readable C# to 20 lines of bad formed Java. It would be a lot nicer to see a Java 8 translation - a lot more comparable.
- mythz 11y agoRight, but Java 8's not available on Android which is a constraint for this library. If that's "bad-formed Java" what's a better functional form? Or do you mean for Java it's better to use an imperative-style with mutating collections?
- jameshart 11y agoIt's better to write code that is amenable to being understood when read. These Java forms accomplish things 'the LINQ way' but at the expense of completely obscuring the intent of the code. LINQ makes sense in C# because the syntax supports a mapping from a declarative query to stream-oriented operations. Without the syntactic support, it becomes unreadable.
- tracker1 11y agoI usually prefer the chaining method extensions for collections myself... Even then it's far easier to follow than the Java examples, or even the Java8 comments... but that's mostly personal preference. I'm also not sure how/if this has an IQueryable interface equivalent, which is pretty cool as well.
- jermo 11y agoYou can't use Java 8 on Android but you can get a lot of its features. RetroLambda library will get you lambdas and streamsupport provides backported Streams API.
- alkonaut 11y agoMakes you wonder why that Java version (the android version) and not Java 8 is used in the comparison. The only conclusion I make from the examples is that I never want to do Android+Java development until Java 8 at least...