Why Android Needed Jetpack Compose
Traditional Android UI architecture
Before understanding Jetpack Compose, it helps to understand how Android traditionally rendered UI on the screen. When we write something like this in XML:
<LinearLayout>
<TextView />
<Button />
</LinearLayout>Android does not directly draw XML on the screen. The XML is first converted into actual View objects in memory. Something like:
LinearLayout object
├── TextView object
└── Button objectThis structure is called the: View Hierarchy (or View Tree). Every UI component becomes a Java/Kotlin object stored in memory.
How Android Draws UI on the Screen
Once this View tree is created, Android performs three important steps:
- Measure Phase
Android first asks every View:
“How much space do you need?”
For example:
* TextView calculates text size
* Button calculates its dimensions
* Parent layouts calculate child sizes2. Layout Phase
After measuring, Android decides:
“Where should each View be placed?”
Example:
* Button below TextView
* Image aligned to center
* Padding and margins applied3. Draw Phase
Finally, Android draws pixels on the screen.
This is where:
* text becomes visible
* colors appear
* shapes and images renderRendering and Skia
Android uses a graphics engine called: Skia. It is responsible for converting UI instructions into actual pixels.
Very simplified:
TextView → draw text
Button → draw rectangle + text
ImageView → draw bitmapSkia converts these instructions into graphics rendered on screen.
Does Android Use GPU?
Yes — modern Android rendering heavily uses the GPU (Graphics Processing Unit).
The GPU helps Android:
draw animations smoothly
render graphics faster
handle complex UI efficientlyInstead of CPU drawing every pixel manually, many rendering tasks are offloaded to the GPU. This is why:
animations feel smooth
scrolling works efficientlyWhy XML/View system became harder for modern apps
A. Large View Hierarchies
LinearLayout
├── RelativeLayout
│ ├── TextView
│ ├── ImageView
│ └── ButtonAs apps became more complex:
more nested layouts
more UI objects
more measure/layout calculationsThis increased rendering complexity.
B. Manual UI Updates
textView.text = user.name
progressBar.visibility = View.GONE
button.isEnabled = trueThis becomes difficult when:
1. screen state changes frequently
2. multiple UI components depend on same data
3. async operations happen continuouslyThis is the heart of modern UI problems.
C. Imperative Programming Style
"Find this View and manually change it."Developers explicitly told Android:
what to update
when to update
how to updateThis worked well initially, but became harder for highly dynamic apps.
D. RecyclerView Complexity
Building dynamic lists often required:
- Adapter
- ViewHolder
- DiffUtil
- notifyDataSetChanged()Which added:
boilerplate
lifecycle handling
state management complexityE. State Synchronization Became Difficult
When application data changed, developers had to ensure every related UI component updated correctly.
As apps became:
reactive
real-time
animation-heavymanual synchronization became harder.
Modern applications were becoming increasingly state-driven, while the traditional View system was still heavily based on manually mutating UI objects.Imperative → Declarative UI shift
The biggest change introduced by Jetpack Compose was not just replacing XML. It changed the entire way Android UI is written and updated.
Traditional Android UI development mostly followed an imperative approach.
In simple terms, imperative UI means:
“Find the UI element and manually tell it what to do.”
textView.text = user.name
progressBar.visibility = View.GONE
button.isEnabled = trueDevelopers had to manually update different UI components whenever application data changed. This worked well initially, but modern apps became:
* highly dynamic
* real-time
* state-driven
* animation heavyKeeping UI and data synchronized manually started becoming more difficult as applications grew larger.
Jetpack Compose introduced a declarative UI approach.
Instead of manually updating Views, developers now describe:
“How the UI should look for the current state.”
Text(user.name)
Here, the UI automatically reacts whenever the underlying state changes.
This introduced a very important shift in Android development:UI = Function(State)
Instead of developers manually updating the UI, the framework itself handles updating only the affected parts of the screen when state changes.
This declarative model is also similar to how other modern UI technologies work, such as:
React
SwiftUI
FlutterThe entire industry gradually moved toward reactive and state-driven UI systems, and Jetpack Compose became Android’s evolution in that direction.
How Jetpack Compose Changed Android UI Development
Jetpack Compose changed Android UI development by moving UI creation from an XML-based View system to a fully Kotlin-based declarative system.
Compose introduced a different approach where UI is built using Composable functions.
Example:
@Composable
fun UserName(name: String) {
Text(name)
}Instead of inflating XML files and manually finding Views, developers now describe UI directly using Kotlin functions. This brought several important architectural improvements.
- UI Became State-Driven
In Compose, UI automatically reacts to state changes. For example:
Text(user.name)Whenever the value changes, Compose updates the affected UI automatically.
Developers no longer need to manually synchronize multiple Views with changing data.
2. Less Boilerplate Code
Traditional Android development often required:
XML files
ViewBinding / findViewById
Adapters
ViewHolder patterns
manual visibility handlingCompose significantly reduced this boilerplate by keeping UI logic and state handling closer together.
3. Better Reusability Through Functions
Since UI is written using functions, components become easier to reuse. Example:
@Composable
fun ProfileCard(user: User)Composable functions can be reused across screens just like normal Kotlin functions.
4. Easier Dynamic UI Updates
Get Tarun Gehani’s stories in your inbox
Join Medium for free to get updates from this writer.
Modern applications frequently change UI based on:
network responses
loading states
user interaction
animations
real-time updatesCompose was designed around this reactive behavior from the beginning.
Instead of manually mutating View objects, Compose reruns UI functions and updates only the necessary parts of the screen.
5. UI and Business Logic Became Easier to Align
Because Compose is fully Kotlin-based, it naturally fits with:
ViewModel
StateFlow
Coroutines
modern reactive architecture patternsThis made Android development feel more consistent compared to switching between XML and Kotlin constantly. Jetpack Compose was not just a UI toolkit upgrade.
It represented a shift toward a more reactive, state-driven, and modern UI architecture for Android development.
Compose Runtime & Compiler
One of the most interesting parts of Jetpack Compose is that it is not just a UI library. Jetpack Compose is actually built using three major parts:
Compiler
Runtime
UI ToolkitMost developers directly interact with the UI toolkit, but the real magic happens inside the Compose Runtime and Compiler.
Why Did Compose Need a Runtime?
In the traditional View system, developers manually updated UI elements whenever data changed.
Compose introduced a different model:
UI = Function(State)
This means whenever state changes, Compose needs a system that can:
detect state changes
understand which UI depends on that state
update only the affected parts of the screenThat responsibility is handled by the: Compose Runtime
The runtime keeps track of which composable functions are using which state values.
When state changes:
Compose reruns only the necessary composables.
Unaffected UI parts can be skipped.This process is called: Recomposition
Instead of manually mutating Views, Compose intelligently reruns UI functions and updates the screen automatically.
Why Did Compose Need a Compiler?
Composable functions may look like normal Kotlin functions:
@Composable
fun Greeting(name: String)But internally, they are handled very differently. The Compose Compiler transforms composable functions into special runtime-aware code.
fun Greeting(
name: String,
composer: Composer,
changed: Int
) {
if (composer.hasChanged(name)) {
Text(name)
} else {
composer.skip()
}
}This allows Compose to:
track UI changes
manage recomposition
skip unnecessary updates
optimize rendering performanceWithout the compiler, Compose would not be able to efficiently understand which UI parts should update when state changes.
Why Recomposition Became Important
In traditional Android development, developers manually updated Views. In Compose, rerunning composable functions is expected behavior. Instead of avoiding UI execution completely, Compose was designed around: cheap and intelligent function reruns
The runtime continuously tries to:
rerun only affected UI
skip unchanged composables
minimize unnecessary workThis is one of the biggest architectural differences between Compose and the older View system.
Jetpack Compose was not simply created to remove XML boilerplate.
It introduced an entirely new runtime-driven approach for building reactive and state-based Android UI.
Why Kotlin Fit Naturally with Jetpack Compose
Kotlin played a very important role in making Jetpack Compose possible.
Compose was designed around:
functions
state
immutability
reactive programming conceptsAnd Kotlin already supported these patterns very naturally.
- UI Became Function-Based
In Compose, UI is written using functions:
@Composable
fun Greeting(name: String) {
Text(name)
}Kotlin’s concise syntax made this style much cleaner compared to older Java-based Android development.
Instead of switching between:
XML layouts
Java/Kotlin classes
View referencesdevelopers could now build UI directly in Kotlin itself.
2. Lambdas and DSL Support
Kotlin’s support for:
lambdas
higher-order functions
DSL (Domain Specific Language) syntaxmade Compose code feel much more readable.
Example:
Column {
Text("Hello")
Button(onClick = { }) {
Text("Click")
}
}This allowed developers to describe UI in a structured and natural way.
3. Better State Handling
Modern Android development increasingly moved toward:
StateFlow
Coroutines
reactive architecture patternsKotlin already provided strong support for these concepts.
Compose integrated naturally with:
ViewModel
StateFlow
Flow
Coroutineswhich made state-driven UI development much simpler.
4. Immutability and Safer UI Updates
Compose works best when UI state is predictable and immutable.
Kotlin’s:
data classes
immutable patterns
null safetyhelped Compose build more reliable and maintainable UI systems.
Similar Evolution Across the Industry
Kotlin and Compose also aligned Android development with modern UI trends across the industry.
Many modern frameworks started following similar ideas:
React uses declarative components
SwiftUI uses function-based UI
Flutter uses reactive widget treesJetpack Compose became Android’s Kotlin-first approach to the same modern UI philosophy.
Jetpack Compose succeeded not only because Android UI needed modernization, but also because Kotlin provided the perfect language features to support a declarative and reactive UI architecture.
Conclusion
Jetpack Compose was not introduced simply to replace XML syntax.
It represented a much larger architectural shift in how Android UI is designed and updated.
Traditional Android development was heavily based on:
mutable View objects
manual UI updates
imperative programming patternsAs applications became more dynamic and state-driven, managing UI this way started becoming increasingly complex.
Jetpack Compose introduced a declarative and reactive approach where:
UI becomes a function of state
Instead of developers manually updating Views, Compose uses its Runtime and Compiler to intelligently track state changes and update only the necessary parts of the UI.
Combined with Kotlin, Compose brought Android development closer to the modern UI architecture patterns already seen in:
React
SwiftUI
FlutterJetpack Compose was not just a new UI toolkit.
It was Android’s evolution toward a more reactive, state-driven, and modern UI architecture.







