openwhisk-runtime-java icon indicating copy to clipboard operation
openwhisk-runtime-java copied to clipboard

Add support for Kotlin actions

Open markusthoemmes opened this issue 6 years ago • 5 comments

Long time ago I came up with instructions on how to run Kotlin on the java runtime in OpenWhisk. Maybe we should add that stuff here?

See: https://github.com/markusthoemmes/openwhisk-kotlin

markusthoemmes avatar Apr 26 '18 06:04 markusthoemmes

We already started work on Kotlin runtime, work under construction once is stable IBM will contribute to Apache OpenWhisk https://github.com/ibm-functions/runtime-kotlin

csantanapr avatar Apr 28 '18 01:04 csantanapr

Hmm, any reason why we'd build a specific Kotlin runtime vs. just using the Java one?

markusthoemmes avatar Apr 29 '18 18:04 markusthoemmes

I think the reason is that java actions don't need kotlin standard library and so to keep the java runtime and java action jar minimal a dedicated runtime (with kotlin-specific stuff bundled) is considered.

mkouba avatar May 09 '18 08:05 mkouba

There's really two reasons for having a specific Kotlin runtime:

  1. Platform and dependencies As @mkouba says, it means that we can embed the Kotlin standard library into the runtime and remove the need to include it in the action. It also means that in the future we have the option to switch to kotlin-native in the future if it makes sense to.

  2. Programming model and customisations It makes it much easer to customise for Kotlin and adopt a more idiomatic programming model. For example, experimental Kotlin runtime does simple things like append the "Kt" to the class name for you. The experimental runtime also adds a data class based API so that you can avoid having to work with JSON directly. The next step would be to look more at how to implement a Kotlin idiomatic async API.

seabaylea avatar May 10 '18 11:05 seabaylea

The experimental runtime also adds a data class based API so that you can avoid having to work with JSON directly.

This is also possible in Java, using e.g. Gson. Of course, java does not data data classes and so it's much more verbose.

This should imho be definitely added to java runtime too.

Kotlin idiomatic async API

Makes sense.

mkouba avatar May 10 '18 11:05 mkouba