Hi, in this blog, we will learn about what is jetpack compose in Android and should we use it? So lets start with that.
What is Jetpack Compose?
Jetpack compose is a modern toolkit from android. It is the recommended framework from Android to build native UI. It is declarative UI framework. And before we learn more about Jetpack compose, lets first understand what is declarative programming.
And also i have youtube tutorial on this topic as well, please checkout here: What is Jetpack Compose ? | Should we use Jetpack Compose ?
What is Declarative Programming?
Declarative programming is all about what to do, but imperative programming is about how to do. So in declarative programming, We only tell the program or functions to what to do, but not about how to do that but instead we only change the state. Example of declarative programming is a Jetpack compose, flutter and react and examples of imperative programming is the traditional programming with in android using java or Kotlin while using XML based layouts.
So in declarative programming we don’t tell the program how to do. We don’t tell the program/function how to do but instead we tell the program/function what to do and just change the state depending upon some events and the program automatically detects what he needs to do depending upon the state changes. So functions automatically rebuild and update the UI depending upon the state changes. And state is the data on which that function depends. This is all about declarative programming for how much it is required for this article, i will cover it with examples in separate article.
Advantages of Jetpack Compose
- Less Code:- Overall code we will have to write is very less than as compared to what we write in traditional xml based Android layouts, because jetpack compose automatically takes care of some low level implementations such as animation automatically.
- Faster Development:- As we will have to write less code, so it will result in faster development, thus reducing the development time.
- More Readable and Easy to Use(Intuitive):- As jetpack compose is based on Declarative UI, so we only need to specify what to do and not how to do, so code becomes more readable and easy to use.
- Reusability:- As we write composable functions in jetpack compose and they are not scoped to any activity, so we can reuse them very easily at wherever we require.
Should we use it?
If you are still thinking about if you should try it or not, then i think you have not understood its advantages that well, what are you waiting for? Some of the popular apps like Twitter, Pinterest, Swiggy, Disney Hotstar, Cuvva and google play store have already started using it. And also compose multiplatform from jetbrains is also coming to the race for making apps for both Android and iOS and even for Desktop and Web using jetpack compose, that will be a huge advantage of learning jetpack compose, because later on you will be able to build apps for multiple platforms using jetpack compose same code.
For checking out which popular apps are built with Jetpack Compose, you can check this link of apps built with jetpack compose. Go and Try it, i bet you will love it And you will not go back to Traditional Android UI development.