Cash App Aug 9, 2023

Poko goes multiplatform

Article Summary

Drew Hamilton just took Poko, the Kotlin compiler plugin that generates equals/hashCode/toString, fully multiplatform. This solves a real API compatibility headache for library authors.

Poko mimics Kotlin data classes but skips the copy and componentN functions that break API compatibility. After 3 years on JVM/Android, version 0.15.0 now supports native and JS targets thanks to contributions from Jake Wharton. Cash App uses it in production for Paraphrase and Redwood runtimes.

Key Takeaways

Critical Insight

Kotlin multiplatform library authors can now ship public data models across all targets without API compatibility concerns.

The performance difference between arrays and Lists on JS is significant enough that Cash App chose API awkwardness over wrapper overhead.

About This Article

Problem

Kotlin data classes generate identical equals, hashCode, and toString functions across JVM, Android, native, and JS targets. However, Poko only supported JVM and Android for 3 years, which meant native and JS platforms weren't covered.

Solution

Drew Hamilton and Jake Wharton extended Poko's compiler plugin in version 0.15.0 to generate these functions for native and JS targets. Now all Kotlin multiplatform platforms have consistent behavior.

Impact

Library authors using Paraphrase and Redwood runtimes can ship public data models to all platforms without API compatibility concerns. The @ArrayContentBased annotation also eliminates List wrapper overhead on JS, which improves performance for generated code.