Why adopt Compose
Less code
Writing less code affects all stages of development: as an author, you get to focus on the problem at hand, with less to test and debug and with less chances of bugs; as a reviewer or maintainer you have less code to read, understand, review and maintain.
Compose allows you to do more with less code, compared to using the Android View system: Buttons, lists or animation - whatever you need to build, now thereโs less code to write. Hereโs what some of our partners say:
- โFor the same Button class it [the code] was 10x of magnitude smaller.โ (Twitter)
- โThereโs also a significant reduction for any screen built with a RecyclerView, which the majority of our screens are.โ (Monzo)
- โWe were very pleased to see how few lines were required to create lists or animations in our app. Weโre writing fewer lines of code per-feature, which allows us to focus more on delivering value to our customers.โ (Cuvva)
The code youโre writing is written only in Kotlin, rather than having it split between Kotlin and XML: โItโs much easier to trace through code when itโs all written in the same language and often the same file, rather than jumping back and forth between Kotlin and XMLโ (Monzo)
Code written with Compose is simple and easy to maintain whatever youโre building. โThe layout system of Compose is conceptually simpler so itโs easier to reason about. Reading the code for complicated components is easier as well.โ (Square)
Intuitive
Compose uses a declarative API, which means that all you need to do is describe your UI - Compose takes care of the rest. The APIs are intuitive - easy to discover and use: โOur theming layer is vastly more intuitive and legible. We've been able to accomplish within a single Kotlin file what otherwise extended across multiple XML files that were responsible for attribute definitions and assignments via multiple layered theme overlays.โ (Twitter)
With Compose, you build small, stateless components that are not tied to a specific activity or fragment. That makes them easy to reuse and test: โWe set a goal for ourselves to deliver a new set of UI components that were stateless, easy to use and maintain, and intuitive to implement/extend/customize. Compose really provided a solid answer for us in this.โ (Twitter)
In Compose, state is explicit and passed to the composable. That way thereโs one single source of truth for the state, making it encapsulated and decoupled. Then, as app state changes, your UI automatically updates. โThereโs less to hold in your head while youโre reasoning about something and less behavior that is outside of your control or poorly understoodโ (Cuvva)
Accelerate development
Compose is compatible with all your existing code: you can call Compose code from Views and Views from Compose. Most common libraries like Navigation, ViewModel and Kotlin coroutines work with Compose, so you can start adopting when and where you want. โInteroperability was where we started integrating Compose, and what we found was it 'just works'. We found that we didnโt have to think about things like light and dark mode, and the whole experience was incredibly seamless.โ (Cuvva)
Using the full Android Studio support, with features like live previews, you get to iterate and ship code faster: โPreviews in Android Studio have been a big time saver. Being able to build out multiple previews also saves us time. Often we need to check a UI component in different states or with different settings -- like error states, or with a different font size, etc. With the ability to create multiple previews we can easily check this.โ (Square)
Powerful
Compose enables you to create beautiful apps with direct access to the Android platform APIs and built-in support for Material Design, Dark theme, animations, and more: โCompose has also solved more than declarative UI -- accessibility apis, layout, all kinds of stuff have been improved. There are fewer steps between the thing you want to make and actually making itโ (Square).
With Compose, bringing movement and life to your apps through animations is quick and easy to implement: โanimations are so easy to add in Compose that thereโs very little reason not to animate things like color/size/elevation changesโ (Monzo), โyou can make animations without requiring anything special -- itโs not different than showing a static screenโ (Square).
Whether youโre building with Material Design or your own design system, Compose gives you the flexibility to implement the design you want: โHaving Material Design separated from the foundation has been really useful to us as weโre building our own design system that often requires differing design requirements from Material.โ (Square)
Check out the in-depth case studies to learn more about how Twitter, Square, Monzo and Cuvva are using Compose.