Advantages of Jetpack Compose

Adhish
3 min readJan 13, 2022
why jetpack compose

Jetpack Compose is a declarative UI framework for Android and thus it brings up a lot of advantages of using it. Here is a summary that elaborates breifly that why we should use Jetpack Compose in our existing and upcoming Android projects —

  • Less code — It uses comparitevly very less code. Like really less! For example, we just need 2–3 lines of code to make a list layout(recycler view) as shown a sample in code below —
  • Intuitive — Jetpack Compose is intuitive. This means it updates the UI automatically according to app state. We just need to describe the UI and rest, compose will take care.
  • Accelerate development — Due to it’s intuitive nature, that is, it updates the UI automatically according to app state, we don’t need to actually run the complete app to see the changes.
  • Powerful — Compose has a native supoort for day night theme and in this animations are really simple. It has a pre-build Animation classes, functions and lambdas which makes the animations happen in less than a line of code! Isn’t this amazing?
    Not only this, since Jetpack compose makes use of Kotlin, it has access to it’s powerful arsenal of features. You can make use of control structures to manipulate the drawing of the user interface. This makes your user interface more dynamic when compared to the ones created using XML layouts.
  • No more XML, just Kotlin — For compose, Kotlin serves as s single source of truth. This means we don’t need to worry about XMLs anymore. All designs of UI is taken care by Kotlin itself and thus you can expect your APK size to reduce as well.
  • Declarative UI — Unlike the most common way of designing the UI, imperative, Jetpack Compose uses a Declarative UI framework. We no longer need to create and maintain separate file(XMLs) for UI and separate for codes(Kotlin). It all happens at one place. And so we save our time thinking for “How?” rather than thinking for “What?”.
  • Compatible with your existing UI — Yes! you read it right. Jetpack Compose is compatible with your existing UI so you don’t need to re-write your whole application. Just use Jetpack Compose.
  • High performance — Compose achieves high performance by measuring children only once. Single-pass measurement is good for performance, allowing Compose to efficiently handle deep UI trees. If an element measured its child twice and that child measured each of its children twice and so on, a single attempt to lay out a whole UI would have to do a lot of work, making it hard to keep your app performant.

Conclusion

In this section we learnt about that what are the benefits of using Jetpack Compose for building the Android UI elements and what are the real advantages of it. If you want to know more about that How Jetpack Compose works or How to get started with Jetpack Compose, please refer to my other blog posts on Jetpack Compose.

--

--

Adhish

A eight plus years experienced, design minded developer with leadership and mentorship qualities who loves to take ownership to get things done in right time.