Kotlin "bytecode"

Is there intentions to crear (if there is none) some kotlin bytecode?
Why? If I have a multiplatform project with libs written in kotlin and with only kotlin code … why do I need to compile and publish to multiple languages?
Futhermore what happens with annotations in libs ?? if I import a pure kotlin with annotations and I want those annotation to be processed in importing projects?
Dynamic libraries… I have a set of pure kotlin libs to be able to be loaded, by any multiplatform project, on runtime.
If I keep on thinking possibly there would be much more cases where an intermediate language is needed.

This is planned, not yet there: https://youtrack.jetbrains.com/issue/KT-52666

It seems unrelated to your request (?). Annotations are retained in libraries, according to their retention config.

I suppose that would require running a compiler inside the runtime, which is not that easy to do.

1 Like

This would require the target language to support this. For example, when compiling for ObjectiveC, you would need ObjectiveC to be able to load that hypothetical Kotlin bytecode. The ObjectiveC team will never had such a feature, so it will never be possible.

Yes and no.

Probably you are already doing something similar to support coroutine for example.

But assuming you are already building rees and other structures while parsing the languag, you already have an intermediate binary representation. Furthermore you already transform into other language.

So it’s creating an intermediate representation and using the libs that create the target language to do in runtime.

Easy? Nope… Not at all. More in languages like the one you comment that the SDK is needed to compile gain an produce dina result

But feasible yes