I know there have been some discussions about Kotl...
# javascript
s
I know there have been some discussions about Kotlin + NodeJS for AWS Lambda, but does anyone have a current example project? Like a hello world? I have a few issues: • how do package, including the Kotlin standard library, etc. • how to exclude some packages, like the AWS package that is provided • how to configure the entry point correctly And before you ask, the reason for doing this is cold-start time. The JVM is killer, and I have some smallish lambdas that I'd like to use but would prefer to use one language throughout my project.
I'd be happy to work with someone to put together such a project as I work through this with some help.
I suppose it's also something we should contribute to https://github.com/JetBrains/kotless
j
I haven’t tried it myself, but GraalVM’s ahead of time compilation should also give you a server-side application that is quick to start and supports the full JVM libraries. I found: https://www.graalvm.org/examples/java-kotlin-aot/
s
My sense was that this would be a much more complicated path... with custom runtimes, etc. My sense is that getting Kotlin/JS on AWS is probably quite simple, but I'm perhaps just missing a few simple configurations.
j
I very much hope you are right. I like Kotlin/JS quite a bit .. but as I experiment I am beginning to wonder if it is stable enough for real-world use. Have you tried it in production?
s
We use it in the browser, with React, and have been quite happy, other than file size, which isn't a huge deal for our internal clients.
👍 1
More digging suggests that the IR compiler will be required (understandable). There is a
compileProductionExecutableKotlinJs
that would seem to be what I'm looking for.
b
My suggestion would be to build it as a regular nodejs app and deploy via terraform. Ping me if you need some help with deployments, happy to help.
First step would probably be writing kotlin external declarations for aws-sdk
m
@steamstreet I created this repo (still WIP) but I was able to get a node js app out of kotlin that is deployable in any node environment. Hope it can be helpfull
s
The IR compiler helped quite a bit, and I was able to make a reasonable Hello World type lambda and deploy it. Was also able to test using kotlin.serialization and that worked as well. Next up, I'll see about making a call to the aws sdk.
👍 1