LINQ is one of Microsoft’s .NET Framework’s most distinct language features. When it was first introduced to languages such as C#, it required heavy changes to the language specification. Yet, this addition was extremely powerful and probably unequalled by other languages / platforms, such as Java, Scala, etc. Granted, Scala has integrated XML in a similar fashion into its language from the beginning, but that is hardly the same accomplishment. Nowadays, Typesafe developers are developing SLICK – Scala Language Integrated Connection Kit, which has similar ambitions, although the effort spent on it is hardly comparable: one “official” Scala developer against a big Microsoft team. Let alone the potential of getting into patent wars with Microsoft, should SLICK ever become popular.
What does Java have to offer?
There are many attempts of bringing LINQ-like API’s to the Java world, as the following Stack Overflow question shows:
Here’s another newcomer project by Julian Hyde, that I’ve recently discovered:
He tried his luck on the lambda-dev mailing list, without any response so far. We’re all eagerly awaiting Java 8 and project lambda with its lambda expressions and extension methods. But when will we be able to catch up with Microsoft’s LINQ? After all, jOOQ, linq4j are “internal domain specific languages”, which are all limited by the expressivity of their host language (see my previous blog post about building domain specific languages in Java).
Java 9 maybe? We can only hope!
10 thoughts on “When will we have LINQ in Java?”
you can use Clojure, Scala or Groovy if you need syntactic sugar. Ex. DSLs, Linq style queries can do with Scala, Closures (Java8 Will have it) and all the goodies. So you can do the brute force in Java and the elegant stuff in those languages that integrate very well with Java and the JVM.
I guess, I could. Then again, why would it be so simple for languages like the ones you mentioned, while it’s so hard for Java to advance?
Even though that was probably a rhethorical question: Java’s stability is only matched by COBOL’s. And that’s one of the main reasons why Java is so successful in enterprise environments, where applications tend to get very old.
This leads to (at least) two constraints for the development of the Java language: If it can be done as a library instead of a language enhancement, don’t add it to the language.
Second, if it needs to be done in the language, try to get it right with the first try. This in itself is already a daunting task, made even more difficult, because language features like to come in bundles (e.g. generics and co-variants). Obviously this needs a lot of time and a lot of thinking.
Being an enterprise developer myself, I am very happy with this conservative and careful way of adding new features to the language.
Yes, given the history of Java’s being reluctant to adding new language features, this was indeed a rhethorical question. Yet, as the upcoming changes in Java 8 proove (lambda expressions, extension methods), these things are not impossible even in conservative environments. You mentioned generics and co-variants, which were quite a bit of a change to the language as well.
There is no such feature in java. By using the other API you will get this feature.
Like suppose we have a animal Object containing name and id. We have list object having animal objects. Now if we want to get the all the animal name which contains ‘o’ from list object. we can write the following query
Above Query statement will list of the animals which contains ‘o’ alphabet in their name.
More information please go through following blog.
You might be interested by LambdaJ:
They have solved this using Proxy objects, making method calls such as “getName()” compile-time safe. Another library that looks just like yours is Coollection: