3 ms·
How is this meaningfully different from the Java 8 Streams API? It seems to be functionally equivalent right up to lazy evaluation, just with SQL vocabulary (s
by Arcsech 8y ago
How is this meaningfully different from the Java 8 Streams API? It seems to be functionally equivalent right up to lazy evaluation, just with SQL vocabulary (select, where, etc) instead of functional vocabulary (map, filter, etc).
- ManFromUranus 8y agoSQL vocabulary is better than functional vocabulary as for many people lot of understanding (and actual use) of set manipulation and transformation starts with SQL. Why have one set of terms for code and a different set on the DB? Thats like saying why is there English, Spanish is functionally equivalent etc. Except that I already learned English (SQL) so why don't you just let me speak English (SQL) in my code?
- emodendroket 8y agoWell, I guess because if you're a Java developer all the other programs you work on will probably use the other set of terms.
- vincnetas 8y agoI recently discovered Java streams. Love it and couldn't notice that example readme could be easily written with streams : List<ProductDisplayInfo> list = Arrays .asList(products) .stream() .filter(p -> p.getCategory() == 2 || p.getCategory() == 5 && isProductUnderDiscount(p)) .map(p -> new ProductDisplayInfo(p)) .collect(Collectors.toList()); https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html https://docs.oracle.com/javase/8/docs/api/java/util/stream/p...
- tytytytytytytyt 8y agoYou should try Scala.
- akdas 8y agoJava streams are great. Having to go from collections to streams (`.stream()`) and back (`.collect(...)`) is annoying, but understandable from a compositional point of view. For fun, you can further reduce the size of the code above (and IMO, make it clearer), but using `Arrays.stream(product)` and a method reference for the `map`: List<ProductDisplayInfo> list = Arrays .stream(products) .filter(p -> p.getCategory() == 2 || p.getCategory() == 5 && isProductUnderDiscount(p)) .map(ProductDisplayInfo::new) .collect(Collectors.toList());
- deleted 8y ago[deleted]
- Arnt 8y agoThe point of LINQ is that it isn't like java streams, it gets to decide where to "where". Java streams read data from spinning rust and then does the selection in RAM. LINQ can send the "where" to the RDBMS and the RDBMS can use an index/btree lookup to read just the data needed where java streams would read umpty megabytes. https://news.ycombinator.com/item?id=17414383 https://news.ycombinator.com/item?id=17414383 BTW
- Arcsech 8y agoYeah, I get that, but this library doesn't appear to be doing that. It seems like it's replicating the facade of LINQ, but not the "hard" parts such as switchable backends, which isn't useful since we already have Streams to handle that use case.
- Arnt 8y agoIt replicates the API and provides a distinctly primitive implementation of that API. By contrast java streams provides an API that can never, ever be implemented in such a way as to issue a clever SQL select. I don't know whether the JINQ people plan to write a good query generator. But if I were the maintainer, my plan would definitely be to focus on the API first and only then work on optimal backend implementation(s).