Another week, another chance to explore the wide world of Android development.
This week, I actually want to step a bit outside of the core Android development experience, and talk about something I’ve been wanting to explore for a while now; server side Kotlin.
If you’re even a little interested in Android development, I’m sure you’ve at least heard of Kotlin at this point. If you haven’t heard of Kotlin, check out some of my other posts to get started.
More might know that Android is now evolving as a Kotlin-First ecosystem.
How To Start With Server Side Kotlin?
I have been asking myself this same question recently, and as I tend to do these days, I reached out to the developer community for advice on how to get started with server side Kotlin. I ultimately received quite a number of helpful comments and suggestions across varying social media platforms:
- Kotlin with Spring Boot seemed to be the most popular choice on LinkedIn
- Twitter was more spread across a variety of frameworks including Spring, Ktor, and others
Before asking the community, I was really only aware of two frameworks for helping write server side Kotlin; Ktor and Spring.
After receiving so many other recommendations, I wanted to share those with you and maybe guide you to some additional resources on the subject.
Frameworks That Support Server Side Kotlin
What is Ktor? Ktor is a Kotlin-based framework for writing asynchronous client and server applications. Because Ktor is built with Kotlin, it takes full advantage of Kotlin language features such as lambda syntax and DSLs.
Ktor is the only of these frameworks that I have any experience with, and I can attest to the ease of setting up a simple project.
The popular server framework Spring Boot includes first-class support for Kotlin. When creating a new Spring Boot application, you can choose Kotlin as the project language to start taking advantage of Kotlin syntax and language features.
If you’re already writing server code with Spring and/or Spring Boot, bringing the power and flexibility of Kotlin to that existing expertise should be a pretty straightforward task.
There’s a nice tutorial on how to build a simple blogging application using Spring Boot and Kotlin if you’re interested to learn more.
One of the frameworks that I hadn’t heard of before is http4k. While I haven’t had time to really explore this yet, it looks intriguing. The project describes itself as an HTTP toolkit for serving and consuming HTTP services via simple Kotlin functions.
On browsing the project documentation, a few things stick out to me: applications as functions, immutability, and a light footprint. As we all strive for faster, more performant services, using a framework with minimal dependencies and a small footprint is an attractive option.
Another framework recommendation was Quarkus, a Java-based Kubernetes framework for building highly performant microservices. Quarkus currently has first-class support for Kotlin as a preview feature of the framework.
Again, I don’t have any personal experience with Quarkus, but at first glance it looks like it is a larger solution than something like Ktor or http4k. If you need to quickly stand up a small service, Quarkus seems like it might be overkill. However, if you are looking for a JVM microservices solution that supports Kotlin, Quarkus seems like it’s worth looking into. Check out their getting started guide for more info.
Frequently Asked Questions About Server Side Kotlin
Yes. You can use Kotlin with JVM server frameworks such as Spring or Quarkus.
Ktor is a Kotlin-based framework for writing asynchronous client and server applications using Kotlin. You can use Ktor to build scalable server applications which can be deployed using any common service such as AWS or Google Cloud.
What Do You Think Of Server Side Kotlin?
What do you think about server side Kotlin? Are you already using it? Are you interested in trying it out as another means of leveraging Kotlin?
Have you had any issues with using Kotlin for server side development?
I’d love to know what you’ve tried, and what has, or hasn’t, worked.
If you’re new to Kotlin, check out my Learning Kotlin series to help you start learning the language.
Here are a few interesting tidbits I’ve come across from the world of Android development: