Popular Kotlin Server-Side Libraries
Victor Darkes
Posted on November 22, 2020
Kotlin is a programming language for mobile cross-platform, native, data science, web, Android, and server-side development.
Kotlin for the Win
Kotlin is a great option for server-side development because it's a modern and concise take on JVM development. If you write Kotlin code there are advantages to using libraries written in Kotlin versus libraries written in Java. Here are some of those advantages.
There is less mental load when interacting with a Kotlin-specific library. That's because there is no context switching when you look at the source code of a library or are trying to debug a library feature. Additionally, Kotlin-specific library APIs are more idiomatic. In Kotlin functional programming is a first-class citizen. Many of these libraries lend themselves to functional programming over equivalent Java libraries meant for object oriented programming. Finally, you can avoid Kotlin platform types. Kotlin platform types appear when you reference Java code from within Kotlin code. The type is not guaranteed as nullable or non-nullable, so you can still run into null pointer exceptions. With all that said, here is a list of popular libraries written in Kotlin.
Web
Ktor - A Kotlin web framework that has the most GitHub stars relative to other options. Can be used with a variety of the other options mentioned in this article.
http4k - A simple and functional HTTP client and server.
Kotless - A Kotlin serverless framework.
Testing
Mockk - A Kotlin mocking library. Mocking is commonly done when writing unit tests. Usually what isn't being tested is what you mock so that your individual test can focus on one function.
Mockito Kotlin - If you're familiar with the Java Mockito library, then this one might be the right choice for you.
Spek - A good option if you're a fan of Jest.
Documentation
Dokka - The official documentation engine for Kotlin. It performs the same role as javadoc in Java.
Dependency Injection
Koin - Has more GitHub stars of the two options. It has a simpler API.
Kodein - A more robust API. Supports Kotlin multiplatform.
Database
Exposed - A Kotlin SQL ORM framework. It supports 7 different databases, including MySQL, PostgreSQL, and MariaDB.
SQLDelight - Generates type-safe Kotlin models from your SQL statements.
Miscellaneous
Okio - An I/O library. If you need to read or write data to a filesystem this is the library for you.
Conclusion
There are a lot of different options for writing server-side Kotlin code. Additionally, many of these libraries are useful for more than just server-side development. Since Kotlin was first released, the ecosystem has matured and provides a lot of different options for Kotlin developers.
If you use Kotlin do make an effort to use libraries written in Kotlin? Or does it not matter to you? Let me know in the comments.
Posted on November 22, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.