https://kotlinlang.org logo
#compiler
Title
# compiler
a

anlex N

03/02/2024, 1:41 PM
hello everyone, when to support the interoperatability of C++ and Kotlin?
c

Chrimaeon

03/02/2024, 2:25 PM
tl;dr it's impossible in full generality unless you are also a C++ compiler
a

anlex N

03/02/2024, 4:02 PM
I am reviewing chromium source code. there, I see that java call c++ thing.
c

Chrimaeon

03/02/2024, 4:04 PM
It’s possible on Java with JNI (Java Native Interface) https://docs.oracle.com/javase/8/docs/technotes/guides/jni/
e

ephemient

03/02/2024, 4:05 PM
you have to wrap every C++ call in JNI manually, you can't call arbitrary C++ from Java directly. you can do the same for Kotlin/Native
in Java's case, the C++ JNI API is just a thin wrapper around the C JNI API anyway; the JVM uses the C ABI to interact with everything
a

anlex N

03/03/2024, 3:02 AM
I don't like JAVA. I hope Kotlin directly can call C++. When will Kotlin have this feature roadmap?
e

ephemient

03/03/2024, 3:15 AM
I expect it will not ever. use C (or C++
extern "C"
) wrappers, like FFI works for practically every other non-C++ language in existence
a

anlex N

03/03/2024, 3:42 AM
@ephemient please show me codes in Kotlin like you says. by the way, who (people) design Kotlin language?
or say who is Kotlin language's father?
can Kotlin do "pass by reference" like C++?