I recently started working on a github project which uses python for scripting throughout
It’s extremely difficult to introduce kotlin (even though I really want to!) due to the fact that the migration would be extensive & very expensive (no simple way to do piecemeal), due to usage of pip (no gradle integration)
I am a huge believer that Kotlin & Rust can replace all [general purpose] systems & environments out there - but in this case, it’s complicated
Given that Kotlin is already beautifully designed with the idea of compile-time environments (expected / actual declarations), and that it already supports compiling to 3 different envs (JS, native, JVM), it seems like it would be straightforward to expand this to be universal, i.e. to support python, dart/flutter, ruby, as target environments
Even if at first there are no common library implementations, e.g. collections, it seems like something the community would/could help with
Interestingly, someone has already taken a stab at this for dart/flutter:
I don’t think it’d be very difficult to do in these other languages, even if at first it just does transpilation
You may need a different tool for the transpilation, but the goal here is:
Produce something which is able to call underlying environment libraries, e.g. existing Python libraries
Produce something which is universal - for example, you could have a single XML parser library, written in Kotlin, usable from: JavaScript, JVM, ObjC, Python, & Flutter/Dart
Supporting additional languages wouldn’t be “easy”. Language ecosystems represent an incredibly large surface area, and so there is lots of engineering involved. That said, in the case of python, I agree 100% that it would be worth the effort, given that Python is the language of AI and being python-compatible would give Kotlin a huge foothold into that rapidly growing ecosystem.
You may be interested in reading through kotlinlang #python. Two people started Python integration, but it’s a lot of work. I think it’s paused at the moment. If you want to help, don’t hesitate to post there and contribute!
I do wonder if that isn’t part of the problem, which is the advantage of an officially-supported offering: if people don’t know about it, they won’t contribute, it dwindles & dies.
That’s true, but once they start advertising it, people expect it to work fairly well, otherwise it gives a bad reputation to their other non-stable projects.
My understanding is that in addition to scripting nature, the main advantage pushing Python is that it easily interacts with C-libraries.
Using Kotlin/Native already interacts with C-libraries and can be compiled as such.
Kotlin/Native also could be compiled into C-library and in that form should be easily called from Python.
How about start with rewriting a Python script in Kotlin, using the same C-libraries and if need to call other Python scripts as external executables? This sounds to me like the path to convert Python scripts into Kotlin one-at-a-time.