I’m new to Kotlin/Native and I wanted to explore it as a replacement for Kotlin/JVM for AWS Lambda. Before I dig to deep I wanted to make sure that Kotlin/Native supports my use cases of networking clients and database drivers.
I have been looking at Ktor Client for networking. I see support for iOS, but not support for Linux. Does anybody know reference that point to examples? Are there any other network clients for Linux?
As for database, I haven’t found anything. I was think this could be done with C database drivers with a Kotlin/C interop. Is this a good approach or are there database drivers for Kotlin that I’m not seeing?
I would love to see the Kotlin/Native team solve these problems. I think it would make Kotlin an exciting alternative to GoLang. If I could get pointed in the correct direction, I might be able to help some.
I want to preface this response by stating that Kotlin/Native is currently in beta status. Keep that in mind before you use it in production because I believe the Kotlin team is still trying to work things out with it, especially speed improvements with the standard library.
Now, on to your question. The Ktor client is built on top of Kotlin Multiplatform, and according to the release notes for Ktor 1.1.2 the client now works on Kotlin Native using libcurl in the background.
I don’t know of any Kotlin Native database drivers, but I’m sure if there’s a native library for the driver in question you can just do interop with it assuming you point the Kotlin Native compiler at the right header files and native libraries.
Kotlin Native should be pretty easy to use and has a lot of nice features like the memScoped block, which will automatically clean up any dynamic memory you allocate within it at the end of the block. I think once it matures more it will be a great alternative to golang, especially once the Kotlin Native coroutines API gets fully stable.
I would also point out that developing in Kotlin Native may not be as free as using it on the JVM or Javascript. There are free versions of IntelliJ that will let you build and debug. If you want to debug Kotlin Native, the only tool for doing so is CLion, which has no free version.
Lambda supports multiple languages through the utilization of runtimes. For a function defined as a container image, you select a runtime and therefore the Linux distribution once you create the container image. to vary the runtime, you create a replacement container image.
When you use a .zip file archive for the deployment package, you select a runtime once you create the function. to vary the runtime, you’ll update your function’s configuration. The runtime is paired with one among the Amazon Linux distributions. The underlying execution environment provides additional libraries and environment variables that you simply can access from your function code. More to know about code join CETPA
When your function is invoked, Lambda attempts to re-use the execution environment from a previous invocation if one is out there . this protects time preparing the execution environment, and it allows you to save lots of resources like database connections and temporary files within the execution environment to avoid creating them whenever your function runs.
A runtime can support one version of a language, multiple versions of a language, or multiple languages. Runtimes specific to a language or framework version are deprecated when the version reaches end of life.