From Java to Kotlin: life without static

TL; DR Java developers new to Kotlin are often confused by the lack of static members. Which options Kotlin provides in order to replace the static keyword? Let's summarize for easy reference: Java static… Replace with… void main() Top-level function Constants Top-level constants Methods in utility class Top-level functions Factory methods Companion object functions Private methods Private companion object functions or private top-level functions in same file Singleton accessors Object instance Continue reading for the details. [Read More]
kotlin  java 

Kotlin closed classes: how to compose with them

One of the most controversial choices by the Kotlin designers was to make classes final by default. This means we need to explicitly open them to allow subclassing. Moreover, functions on an open class must also be explicitly marked open to allow a subclass to override them. There were a lot of debate even before Kotlin 1.0 came out, as illustrated by this thread in the Kotlin forum. The main objections against defaulting to closed classes are the following: [Read More]

Java interoperability: Kotlin vs Scala

While working at a Scala company a few years ago, I documented a few pitfalls regarding Scala / Java interoperability. When I started looking into Kotlin I was curious to see if Kotlin had better interoperability as claimed or if it had the same issues than Scala. Most of the issues mentioned below stems from badly defined Java code, but they are all issues I have actually experienced in the wild. [Read More]
kotlin  scala  java