When will we have LINQ in Java?


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:

http://stackoverflow.com/questions/1217228/what-is-the-java-equivalent-for-linq

Here’s another newcomer project by Julian Hyde, that I’ve recently discovered:

https://github.com/julianhyde/linq4j

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!

Tags: , , , , , , ,

10 responses to “When will we have LINQ in Java?”

  1. Miloskov says :

    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.

    • lukaseder says :

      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?

      • Frisian says :

        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.

        • lukaseder says :

          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.

  2. vishnu says :

    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

    from(animals).where("getName", contains("o")).all();
    

    Above Query statement will list of the animals which contains ‘o’ alphabet in their name.
    More information please go through following blog.
    http://javaworldwide.blogspot.in/2012/09/linq-in-java.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 2,084 other followers

%d bloggers like this: