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
- Poko 0.15.0 adds native and JS support alongside existing JVM/Android
- New @ArrayContentBased annotation enables content comparison for performance critical code
- Arrays on JS avoid List wrapper overhead, crucial for generated code runtimes
- Generated functions behave identically across all Kotlin multiplatform targets
Kotlin multiplatform library authors can now ship public data models across all targets without API compatibility concerns.
About This Article
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.
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.
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.