Jetpack Compose is a UI toolkit for Kotlin that’s designed to help developers create modern apps across all Android platforms.
“No matter where you’re working from, whether it’s your kitchen table or an office, we know you need a programming language, an IDE and a powerful UI framework that can save you time and reduce how much code you need to write,” Google’s Karen Ng explains. “So we built Jetpack Compose to make you (and us!) more productive with building UI.” (The other two components are covered by Kotlin and Android Studio, respectively.)
Jetpack Compose is built to work with Kotlin and Android Jetpack, a set of code libraries aimed at helping developers “follow best practices, reduce boilerplate code, and write code that works consistently across Android versions and devices,” that is used by over 80 percent of the top 10,000 apps in the Google Play Store. Similar to the Flutter/Dark cross-platform solution, Jetpack Compose lets developers create user interfaces using declarative code.
It’s early yet, but the current alpha version of Jetpack Compose includes APIs for animations, constraint layout, input and gestures, Views interoperability, lazy lists, Material UI components, performance optimizations, testing, text and editable text, theming and graphics, and window management.
“Historically, an Android view hierarchy has been represented as a tree of UI widgets,” Ng says. “Compose uses a programming model that is quite different from [that] existing model … [It] is a fully declarative component-based approach, meaning you describe your UI as functions that transform data into a UI hierarchy. When the underlying data changes, the Compose framework automatically updates the UI hierarchy for you, making it simple to build UIs easily and quickly.”
Jetpack Compose is also supported by tooling in Android Studio, including an interactive Compose layout preview that lets you to preview your Compose components without having to deploy your app to a device or emulator.
This looks very interesting, but as a fan of Flutter, I’m curious how it compares and why a developer might choose one over the other.