Kotlin 1.2.70 was just released. If you’ve upgraded to it, you might have noticed some new IntelliJ warnings telling you that “Call chain on collection should be converted into ‘Sequence’”. Applying the suggestion adds a couple of extra function calls to the call chain. Is this extra code useful?

The release announcement says this:

Using Sequences helps avoid unnecessary temporary allocations overhead and, may significantly improve performance of complex processing pipelines

“significantly improve performance”? Claims like that make me skeptical when they don’t have any measurement to back them up, so let’s figure out if it’s true.

Before we dig…


Yesterday I had a co-worker come to me with an interesting bug in a Kotlin class he was writing. He had a read-only property with an inline initializer like this:

class MyProgressBar(context: Context) : ProgressBar(context) {
val bounds = Rect()
override fun setProgress(progress: Int) {
super.setProgress(progress)
with(bounds) {
val right = left + ((progress.toFloat() / max) * width)
set(left, top, right.toInt(), bottom)
}
}
}

Even though there were no IDE or lint warnings, when he tried to create an instance of that class, it would crash with a NullPointerException when trying to read the bounds property.

“How can a…


XKCD, Randall Munroe // CC BY-NC 2.5

If you convert an app from Java to Kotlin, will it take longer to compile?

This is part 3 in a series of articles on Kotlin. Part 1 discussed converting an Android app from Java to Kotlin, and part 2 contains my thoughts on the Kotlin language.

In an earlier article, I discussed converting an Android app from Java to 100% Kotlin. The Kotlin codebase was smaller and more maintainable than it’s Java predecessor, and so I concluded that the transition was worth it. But some people don't want to try out Kotlin because they are worried that it might…


Photo By Johhy Silvercloud / CC-BY-SA

In my last article, I talked about converting Java codebases to Kotlin, and about some of the libraries I like. Here, I’m going to talk about my thoughts on the Kotlin language itself and the way it interacts with Java.

The Good

There’s a lot to like about Kotlin. Some of the obvious features like null safety, property access, and unchecked exceptions are covered at length in other publications, so I won’t repeat them here. Instead, here are some of the less commonly discussed features of Kotlin that I really like.

Automatic conversion of Java to Kotlin

JetBrains’ Java to Kotlin converter integrated into IntelliJ saves a huge…


This is part one in a series of posts about Kotlin. Click here for part 2, where I discuss the design of the Kotlin language.

I’ve been following the development of Kotlin for a while. Kotlin is a relatively new language that primarily targets the JVM, and is interoperable with Java. With the release of Kotlin version 1.0.2, which brought incremental compilation and a large reduction in the number of methods in its standard library, I was eager to start using it in production.

I’m the lead engineer on App Lock at Keepsafe, which, like most Android apps, was written…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store