Hi! I was wondering if Kotlin/KJS could be a good ...
# javascript
e
Hi! I was wondering if Kotlin/KJS could be a good match to write a database client library that would perhaps be used more frequently from JavaScript, TypeScript and Java than from Kotlin or Kotlin/JS, at least for a start. The current implementation is pure JS and has no TS types. Writing the code on TypeScript and making it callable from K/JS sounds absolutely doable, but the attractive thing here is to also generate a Java client. It seems to me there's some focus going on in making existing JS/TS libs easily accessible but how about the other way? Can I write a single codebase in Kotlin code in such way that it is easy and natural to call from Java/JavaScript/TypeScript? Does this sound like a practical thing to do? What can I expect in terms of added K/JS runtime size? Thx!
a
In theory, yes, but in practice, this is very difficult to achieve. Suggest you search for typescript in this channel and take a look at the various reports people have posted on the limits of the current functionality.
c
i think for now it work very well for java and not so well for javascript and typescript. for TS interop you need the IR backend. for bundle size you will need es6 support. i don’t know if there is an ETA for that but es6 support seems at least a year away.
the current focus of kotlin MPP seems to be to share common application logic for an app, not to write multi platform libs that are callable from other languages than kotlin.
👍 1
e
makes a lot of sense, thanks! exactly the kind of answer that I was looking for.