Jetpack Compose is new, exciting, and (to some) deeply weird. So, here are some fictionally-asked questions (FAQ) to try to address common concerns.
We have to start somewhere, right?
What Is Jetpack Compose?
Jetpack Compose is the next-generation UI toolkit for Android app development.
It is meant as a replacement for the
View-based system that we have been
using since Android’s introduction over a decade ago.
Why Do We Need This?
View hierarchy mechanism that we have been using was a reasonable
choice way back when, it has its issues in modern app development:
Views tend to maintain their own state. As a result, we are constantly having to deal with synchronizing between other representations of state (e.g., models) and the views. And, all too often, those state representations get out of sync. The idea behind Jetpack Compose is that our models should be the single source of truth for our state.
Views have a mishmash of callbacks, none of which are particularly amenable to modern reactive frameworks. Jetpack Compose is aiming to be very coroutines-friendly.
Viewand many of its subclasses (e.g.,
TextView) are absolutely massive in terms of code size, owing to their dependence upon inheritance. Jetpack Compose is designed to try to decouple as much logic as possible and reduce (if not outright eliminate) inheritance as a concern.
Viewand most of its major subclasses ship as part of the firmware (“framework classes”). These cannot be updated by Google except through OS releases, whereas Jetpack Compose will be shipping in the form of libraries for more rapid revision. The behavior of
Viewand its subclasses may vary by OS version, or even by manufacturer; Jetpack Compose should only vary in terms of library versions.
When Will Jetpack Compose Ship a Stable Release?
Nobody knows. It is likely that even Google does not know. Given the current pace to date, 2021 seems like a probable (if large) target timeframe.
When Will Jetpack Compose Ship an Alpha Release?
Google probably has some ideas about this, but they are not saying. In the absence of COVID-19, it might have been reasonable to predict an alpha release in the first half of 2020. Now, “all bets are off”.
Should I Be Using Jetpack Compose Now?
If you wan to experiment with “bleeding edge” technology, then you will have plenty of opportunities to bleed with Jetpack Compose.
On the one hand,
there is a lot of work to be done with Compose and the APIs are likely to be
very fluid. As a result, anything that you write today using Compose probably
will need to be revised a lot as Compose development continues. Plus, Compose
does not cover everything in the existing
View system, particularly when it
comes to the sorts of things that you need to use third-party libraries for.
As a result, working with Compose right now is a continuous experience in pain,
with occasional bouts of “hey, that worked!”.
On the other hand, it is likely that Google is going to be promoting Jetpack Compose as the preferred direction for Android app development in future years. If you want to “get ahead of the curve”, there is no time like the present!
Do I Need Special Stuff to Use Jetpack Compose?
Mostly, you will need the latest Canary edition of Android Studio. If you are used to Canary builds, then you know what to expect. If you are the sort of developer who usually sticks with stable Studio releases… Canary builds are not stable.
Why is Google Developing Jetpack Compose?
Mostly, for the reasons outlined in the “Why Do We Need This?” question above.
Partly, it is because Apple is developing SwiftUI, which fills the same basic role in iOS as Jetpack Compose does in Android. Competitive pressures are a wonderful thing!
The Weird Stuff
jetc.dev, we are all about the weird stuff.
Why Do I Crash?
Right now, Jetpack Compose and coroutines do not work well together, due to some
limitations in the Kotlin compliler plugin. Not everything with Compose and coroutines
will fail, but expect problems and crashes when trying to use
@Composable functions together.