https://kotlinlang.org logo
#intellij
Title
# intellij
k

Klitos Kyriacou

10/27/2023, 3:26 PM
This is a long shot, but thought I'd try: Just as when you paste Java code into a Kotlin file, IntelliJ offers to translate it automatically into Kotlin for you, is there any plugin that can translate if you paste Python code?
h

hfhbd

10/27/2023, 4:01 PM
You could write a plugin, which supports the python language and is able to map the python ast to valid Kotlin code, including keeping the semantic. While it is not impossible, having universal support is hard.
👍 1
k

Kirill Grouchnikov

10/27/2023, 7:35 PM
Java to Kotlin is simpler because Kotlin is very much built to be a “natural” extension of Java
h

hfhbd

10/27/2023, 7:41 PM
Yes, you do use the same api, the Java library as well as the same target, jvm bytecode, so there is no behavior change. Also the syntax is similar which results into readable transformed code too. Beside generating the same behavior from python with Kotlin producing readable code is another challenge.