my2iu / Jinq

LINQ-style queries for Java 8
Other
659 stars 71 forks source link

Kotlin support #81

Open IceBlizz6 opened 4 years ago

IceBlizz6 commented 4 years ago

Hello I would like to advocate for Kotlin support.

I found this thread on stack overflow https://stackoverflow.com/questions/40064479/jinq-in-kotlin-how-to-convert-lambda-into-java-serializedlambda

I encountered the same problem. "This error sometimes occurs because your lambda references objects that aren't Serializable."

Would you still consider adding Kotlin support in the near future? If needed i can provide a sample project.

my2iu commented 4 years ago

I don't think I will be able to add Kotlin support any time soon. It would probably involve a few weeks of work. Plus, on-going maintenance would be needed to ensure that Jinq tracks the latest Kotlin compiler output as Kotlin evolves. I just can't justify that sort of time commitment for this project.

IceBlizz6 commented 4 years ago

I really appreciate your work on Jinq, i'm using this library for both work and home projects.

You mentioned in the stackoverflow thread that you implemented support for Scala. Do you think Kotlin support would require a larger time investment? Do you know what the difference could be between Kotlin and Scala lambdas?

my2iu commented 4 years ago

There is support for an older version of Scala, but Scala kept changing its compiler output, and I couldn't spend the time to keep the Scala version of Jinq updated for newer versions of Scala.

Kotlin would probably require a similar time investment of a month or two in order to decompile some Kotlin lambdas and figure out how Kotlin compiles its lambdas into Java bytecode. Then a special Kotlin-variant of the Jinq API would need to be created in order to properly support the Kotlin collection library. And there might be some work involving getting things integrated with Kotlin tooling.

I haven't put in any time to decompiling some Kotlin lambdas to figure out what its output looks like, so I have no idea how it compares to Scala lambdas, or if it's even feasible to support it with Jinq.

IceBlizz6 commented 4 years ago

Thank you for the descriptive answer. Ill keep a separate .java file in my Kotlin project for jinq. They are compatible so this is not a complete blocker.

I mainly wanted you to know that there are some interest in this. Perhaps in a distant future both of these languages may become more stable and popular, then it may be worth looking into this again.

my2iu commented 4 years ago

It's pure speculation on my part, but I think if Kotlin gets popular enough and there was strong demand for something like Jinq, the Kotlin people would probably just make their own thing. I imagine they would probably want a solution that works on Android and other platforms too, which would disqualify Jinq.

cromat commented 3 years ago

@IceBlizz6 Another option would be QueryDSL which is quite similar. Here are some examples.