Choosing Kotlin for your microservices

With so many languages available to develop our backend services, why would we choose Kotlin? As we've seen throughout this book, Kotlin is a powerful modern language. It's expressive, it's concise, it has a terrific standard library, and it's fully compatible with any existing Java framework you may want to leverage in your service. Kotlin is also well suited to highly asynchronous programming through its support for coroutines. Finally, Kotlin has excellent tooling with which to build and debug your services. All of these factors add up to a very productive development experience for Kotlin on the backend.

Adding to the potential benefits of using Kotlin to build a microservices architecture is the Ktor framework. Ktor is a Kotlin-based framework for building asynchronous client and server code. Ktor takes advantage of Kotlin's features, including higher-order functions and custom DSLs, to provide a framework that is very Kotlin idiomatic and easy to use as a Kotlin developer. Ktor also supports Kotlin multiplatform, enabling developers to share Kotlin code between their backend services and client code.

In the next section, we're going to build our own service using Kotlin and Ktor. We'll walk through the setup process, write the simple service, and then deploy our service locally so that we may start developing against it.