Hi folks! I'm working on a Python backend for Kotl...
# datascience
p
Hi folks! I'm working on a Python backend for Kotlin. I'm wondering if you'd like to see Kotlin <-> Python interop when it comes to data science. Please share your use cases in #python
a
Could you clarify a bit about what do you mean? Do you want to run python interpreter in Kotlin-jvm or compile kotlin into python?
p
The latter
Think of it like another backend
a
Why do you need that. Even if you manage to do that, it seems it would combine worst parts of Python and kotlin.
p
Here I'm asking for extra use cases from the point of data science
a
Well, you can try to do so. But most of your problems are solved with kotlin scripting. Integration with Python scripts doe not make any sense since you can just run them as separate processes. Also graalvm polyglot already allows mixing Python and jvm.
p
Sorry, I don't fully understand. GraalVM - it needs the runtime to be present on the target machine which is not always possible or desirable. Kotlin scripting works only for JVM, and sometimes it's not available. Application scripts - again, not always desirable to install the JVM where the application has Python runtime already bundled. Also, inter-process communication is some additional complexity. In general, this project is an experiment, so far mostly for fun. I'm looking for other real-life use cases just to be aware of them :)
a
Well, I can understand fun. And it is a great practice in compilers.
👍 1
s
Still, any ideas of use cases, even "fun" ones, are very welcomed
👍 1
i
@Piotr Krzemiński this is an interesting idea, "Let's-plot" would certainly benefit if Kotlin could support "Python" target. (https://lets-plot.org/)
true story 1
p
Thanks @Igor Alshannikov! How does Lets-plot do Python interop? Through native code somehow?
i
We build a tiny cython module (https://github.com/JetBrains/lets-plot/blob/master/python-package/kotlin-bridge/lets_plot_kotlin_bridge.c) - a bridge between python and our native binaries. The module used C, the rest is in Kotlin and the "C interop" in between.
р
@Piotr Krzemiński well use kotlin-native if you can write pure kotlin (without any addition) and get a shared library out of it. Then it's easy to call from python
the problem comes always when you want to use some JVM library from within python and here I am afraid the only solution you will have is IPC or libjava.so (but good luck with that)
in practice (as it happens often) solutions based on polyglot message brokers are simplest and more maintainable solutions to those type of problems
just breakdown your task correctly
@Piotr Krzemiński have a look also at NPM's communicator https://github.com/mipt-npm/communicator
👍 2
p
Thanks, however I'm more interested in use cases specifically for a Python backend. What you propose is another approach to some problem that the Python bsckend may help solve