Have You Tried Server Side Kotlin For Backend Services?

Have You Tried Server Side Kotlin?

You are reading “Goobar,” an Android development newsletter exploring the latest tools, tips, and trends from the world of Android. We’re dedicated to helping you learn and grow in your career as an Android developer, so if you like what you see, be sure to subscribe.

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.

Welcome devs 👋

Another week, another chance to explore the wide world of Android development.

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.

Because of the strong Android support for Kotlin, I still find developers that believe Kotlin is only applicable within the domain of Android development.  This couldn’t be further from the truth. Not only does Kotlin support multiplatform projects, and transpiling down to JavaScript, but Kotlin is a terrific language for server side development as well.

Anyone out there using server side Kotlin? Click To Tweet

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:

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

Ktor

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.

Spring Boot

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.

Http4k

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.

To read more about the goals and ideas behind this project, you can check out their rationale page, or jump over to the quickstart page to see how you can get started.

Quarkus

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

Can Kotlin be used to write backend, or server side, code?

Yes. You can use Kotlin with JVM server frameworks such as Spring or Quarkus.

Can I use Kotlin for Web development?

Absolutely. You can use Kotlin with frameworks such as Spring Boot or Ktor to write server side code. Additionally, Kotlin can be transpiled to JavaScript and can be used to work with common JavaScript frameworks such as React.

What is Ktor?

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.

Interesting Tidbits

Here are a few interesting tidbits I’ve come across from the world of Android development:

More weekly Android (and Kotlin) discussion


What in the world of Android development are you interested in right now? Join in the conversation in the comments below.

See you next time devs 👋



Categories: Newsletter

Tags: , , , , ,

Leave a Reply