Kotlin ‘immutability’ is just an illusion
When I tried Kotlin for the first time, I quickly noticed the distinction between List<T> and MutableList<T> types in Kotlin collections API. I really liked it, until I discovered how it works. Then I tried to use some defensive programming techniques to prevent using certain implementations. It turned out that they also don’t fully work […]
Efficient test startup: Kotest + Micronaut + Testcontainers
A couple of months ago I published an article, where I showed how to bind Micronaut, Testcontainers and JUnit together. Recently, a new version of Micronaut arrived (3.5) that added the support for Kotest 5 framework. It targets Kotlin language. This is a great opportunity to get back to the topic and try out another […]
Update operators in MongoDB
MongoDB is a popular database choice for projects that need flexibility and good horizontal scaling. While newer versions support transactions, MongoDB still works the best without them. To achieve data consistency, we can use MongoDB update operators. They can make our writes much smarter, especially if we learn a couple of patterns. In this article, […]
Manage your dependencies with Gradle version catalogs
Since the very beginning, Gradle build system relied on Maven artifacts for managing dependencies and their versions. It was a good move from the adoption point of view (access to large library repositories). However, it also meant that for a long time, Gradle lacked a couple of very useful native features. A central place for […]
Immutable classes in Java and Kotlin
If we write code that runs on more than one thread, sooner or later we meet the idea of immutable classes. The lack of ‘write’ functions makes them very useful in multi-threaded applications. In this article I’m going to show what immutable classes are in Java and Kotlin. We will also look at the practical […]
Java records vs Kotlin data classes
Records and data classes are two very similar types of classes in Java and Kotlin. Despite almost the same look and feel, there are also a couple of differences between them. Recently, I had a chance to try out records after writing exclusively in Kotlin for almost a year. In this article I would like […]
How to abuse Kotlin extension functions
Today we’re going to discuss Kotlin extension functions. It’s a mechanism that allows adding new functions to existing classes that we can’t normally modify (e.g. because they come from another library). Calling an extension function looks like a regular function call on an object. Kotlin isn’t the first language that offers them. Only in JVM […]