Is anyone interested in compiling Kotlin into Pyth...
# multiplatform
p
Is anyone interested in compiling Kotlin into Python? If so, please share your use case in this thread. Together with @SerVB we're working on compiling Kotlin to Python (#python). The more data about real use cases we have, the better we can do in terms of deciding on MVP's scope!
K 2
h
This is incredible, nice work! My use case: We have a big data streaming application, based on Kafka. We get every second new data, which has to be processed by ML models. These models are developed in Python, using keras/pyod etc. To execute the models we use a fastApi server, which gets simple arrays serialized with Json, converts the json to
nparray
, calls the model and convert the results back to json arrays. It would be perfect, if we could define the data classes in Kotlin, to switch from double arrays to typed classes. Sharing the definitions with the Python server would help us to not have incompatible definitions at runtime. Depending on the interoperability we would also switch from fastAPI to Ktor :)
🙏 1
👍 1
i
I am thinking to do a multiplatform project using python to show plot in the ui writing only once for ios and Android
❓ 1
p
@ivano sorry, not sure if I get what you mean. Our project is about using Kotlin and then transpiling it to Python so that you can use Kotlin with a Python runtime. Form what I understood from your use case, you want to use Python as a language to write multiplatform apps. Or you want to use Kotlin language and Python libraries?
i
Yes first use case i want to use Python as a language in a mobile multiplatform project so that can reuse my pandas, plotlib files directly into the project and also visualizing them in the UI without the need to rewrite swift ui for ios and compose for android. I know is another aim than the python project in the community you are busy but as soon as I read your post wanted to write my user case even if I am aware the python project from the community is quite different because I wanted to make aware that also reusing existing python in kotlin may be not a bad idea for his simplicity, diffusion, easy syntax, and mainly for the huge community and existing huge availability of snippets of code
👍 1
p
Yep, full inteorp would certainly be nice :) Our first milestone is unidirectional Kotlin to Python compilation, and consuming such generated Python from existing Python won't be supported yet. But it's certainly something to look at next.
h
@Piotr KrzemiƄski You do write a new compiler backend, dont you? Which approach did JetBrains when developing the Kotlin jupyter kernel, "just" creating Kotlin wrappers over the C API? https://github.com/Kotlin/kotlin-jupyter Unidirectional would be fine! The biggest challenge is library support
p
Yes, a new compiler backend. Great question, will take a closer look at it, thanks! However we're in touch with the Kotlin compiler team and if they did something similar as we, we'd probably know :D
"Kernels are programming language specific processes that run independently and interact with the Jupyter Applications and their user interfaces". So I assume it's a regular Kotlin/JVM compiler bundled with logic that calls appropriate Jupyter API.