• The lysine contingency

    I’m happy to announce that Retrofit, OkHttp, and Okio are moving to a new GitHub organization, and along with SQL Delight are all joining the Commonhaus Foundation. You can read their announcement of the move. This move is meant to reinforce our commitment to these projects’ longevity and honor the fact that they’ve long since…

    Read More

  • Live coding with dir stepper

    Two months ago I gave my first ever live programming talk at KotlinConf. It was called “Talking to terminals (and how they talk back)”, and you can watch it here. I’ve previously done slide-heavy talks which contained small demos or navigating through an existing codebase. Since this talk was starting from nothing, I decided to…

    Read More

  • Compose & kotlinx.html

    Let’s render a simple page with Ktor server and kotlinx.html: get(“/users.html”) { call.respondHtml { myLayout(title = “Users”) { userList( users = db.users.value, ) } } } A reusable myLayout provides scaffolding, userList encapsulates the specific page content, and db.users is a StateFlow<List<User>> from the persistence layer. I’ve been doing this over and over to create…

    Read More

  • Deprecating idling resource libraries

    When Espresso was made public a decade ago, one of its banner features was the “idling resource” concept. This monitored the main thread and any background thread pools to prevent your test from progressing until the app became idle. Waiting until idle generally increased the stability of tests since at that point the UI should…

    Read More

  • Compile-time validation of JNI signatures

    JNI allows managed code inside the JVM or ART to call into native code. Java methods can be declared as native, and then a corresponding C function1 can be written and automatically wired together when the native library is loaded. Native code lacks mechanisms like packages and overloads, so a special format is used to…

    Read More

  • Fan-in to a single required GitHub Action

    It doesn’t take long for a project to spawn multiple jobs in their GitHub Actions. Parallelization can lead to huge speedups for PRs. Job grouping makes it easier to conditionally enable or disable multiple steps. Each time you add a new job, however, you have to mark it as required in branch protection to prevent…

    Read More

  • Custom short-link redirector

    I used to use Bit.ly to put links into my presentations. Their service allowed you to customize the path portion of the link, so I was able to create links like bit.ly/ok-libs. If you were attending the talks live, watching the recording, or browsing the slides, the short URL was easy to type into a…

    Read More

  • You should use AndroidX betas

    Did you know the versioning of AndroidX libraries and their stability guarantees are different from most libraries? Their betas and RCs are actually production-ready, and you should be using them! In a “normal” library, such as the ones I release, features are added and known bugs are fixed to produce a stable release which might…

    Read More

  • Intermediate collection avoidance

    Given a list of users, extract their names and join them into a comma-separated list. Kotlin’s extension functions on collections make this trivial. users.map { it.name }.joinToString() Writing this in IntelliJ IDEA produces a “weak warning” offering advice. Call chain on collection type may be simplified An intention action will refactor the code for you…

    Read More

  • Perils of duplicate finding

    Given an array of integers ([1, 2, 3, 1, 3, 1]), find the elements which are duplicated. No, we’re not interviewing. I’m trying to prevent a user from specifying a reserved value twice. Elsewhere in the file I already have duplicate detection for object tags. val dupes: Map<Int, List<Widget>> = widgets.groupBy(Widget::tag) .filterValues { it.size >…

    Read More