Spotlight on libraries: Top 5 open source libraries for Kotlin

We’ve already gone over our favorite IDEs and text editors for Kotlin, now we’re taking a look at libraries! In honor of the recently released Kotlin 1.3, today we’re going to explore some of our favorite libraries to really extend our use of Kotlin.

Kotlin 1.3 just dropped, so go check it out if you haven’t already. This release includes a lot of goodies like stable coroutines, a Kotlin/Native beta, Ktor 1.0 beta, and significant progress for other multiplatform projects.

However, we’re mostly interested in Kotlin libraries today, so it’s time to use your quiet voice and check out some of these awesome projects for Kotlin. As always, this list is subjective. There are an awful lot of options out there. We just can’t cover every one of them, even though, statistically speaking, most of them are awesomesauce.

Following the footsteps of RxJava and RxAndroid, RxKotlin is a lightweight library that adds convenient extension functions to RxJava. Although developers can already use RxJava out of the box for their Kotlin projects, the RxKotlin library has extra language features for things like extension functions to streamline the process even more.

Essentially, RxKotlin just collects all of these easy hacks together in a centralized library as well as standardizing conventions for using RxJava with Kotlin. In fact, RxKotlin can be used in conjunction with other libraries without any overlap or dependency issues.

Much like the sweet dumpling, Anko is a Kotlin library that makes life better. In particular, this kind of Anko makes Android application development faster and easier. Anko’s lightweight library is full of helpers for intents, dialogs, logging, resources, and more.

This toolbox also comes with Anko Layouts, a fast and type-safe approach for writing dynamic Android layouts. There’s Anko SQLite, a Kotlin-specific query DSL and parser for Android SQLite, as well as Anko Coroutines, which are utilities based on the new kotlinx.coroutines library.

A lightweight JavaFX framework for Kotlin, TornadoFX allows developers to create maintainable applications powered by our favorite statically-typed JVM language. TornadoFX offers developers a rich set of extensions so they can take advantage of all the features common to JavaFX, including Wizard, Form, DataGrid, Drawer, and more.

This library also offers first class support for FXML, a built-in dependency framework for code management, and a built-in Rest and JSON client. However, it needs to be noted that TornadoFX is not yet compatible with Java 9+. The team is waiting for JavaFX to be fully and stably decoupled from the JDK before making it compatible.

Based off of the Mockito extension for Java, Mockito-Kotlin is a wrapper library that provides developers with extra helper functions in Kotlin. Mockito (the Java version) is one of the most popular Java libraries around, with a large StackOverflow community. The Kotlin extension is merely bringing all that awesome testing to Kotlin developers.

Developers can utilize a more idiomatic approach while still using Mockito in Kotlin. Essentially, this mocking framework is used for unit tests. With a simple API, developers can write beautiful and useful tests with clean verification errors.

Afraid of needles? Don’t worry about your dependency injections; Kodein is on the case! This library offers painless dependency injections for Kotlin. Kotlin allows developers to bind their business unit interfaces with implementation, making every business unit independent.

This simple, easily configured dependency retrieval container works on the JVM, Android, JavaScript, Node.js, and on iOS. Developers can lazily instantiate their dependencies when needed and stop caring about dependency initialization order. Classes or interfaces are easily bound to their instance or provider. Plus, it’s easy to debug dependency bindings and recursions with Kodein!

Honorable mentions

We’ve already done an entire article about Haven, the safest place to manipulate your JSON data in Kotlin. There’s also another article in our archives about Arrow, which shines for bringing functional programming into Kotlin. Last, but never least, is Kotlin Koi, a lightweight library for Android, which includes lots of useful extensions, async functions, and a quick adapter.