Sitemap
Tarun Gehani

Tarun Gehani

9+ years with Gradle fellow.

Why Android Needed Jetpack Compose

8 min readMay 19, 2026
Press enter or click to view image in full size

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 object

This 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:

  1. 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 sizes

2. Layout Phase

After measuring, Android decides:

“Where should each View be placed?”

Example:
* Button below TextView
* Image aligned to center
* Padding and margins applied

3. Draw Phase

Finally, Android draws pixels on the screen.
This is where:
* text becomes visible
* colors appear
* shapes and images render

Rendering 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 bitmap

Skia 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 efficiently

Instead of CPU drawing every pixel manually, many rendering tasks are offloaded to the GPU. This is why:

animations feel smooth
scrolling works efficiently

Why XML/View system became harder for modern apps

A. Large View Hierarchies

LinearLayout
├── RelativeLayout
│ ├── TextView
│ ├── ImageView
│ └── Button

As apps became more complex:

more nested layouts
more UI objects
more measure/layout calculations

This increased rendering complexity.

B. Manual UI Updates

textView.text = user.name
progressBar.visibility = View.GONE
button.isEnabled = true

This becomes difficult when:

1. screen state changes frequently
2. multiple UI components depend on same data
3. async operations happen continuously

This 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 update

This 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 complexity

E. 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-heavy

manual 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

Press enter or click to view image in full size

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 = true

Developers 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 heavy

Keeping 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
Flutter

The 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.

  1. 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 handling

Compose 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 updates

Compose 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 patterns

This 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 Toolkit

Most 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 screen

That 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 performance

Without 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 work

This 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 concepts

And Kotlin already supported these patterns very naturally.

  1. 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 references

developers 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) syntax

made 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 patterns

Kotlin already provided strong support for these concepts.

Compose integrated naturally with:

ViewModel
StateFlow
Flow
Coroutines

which 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 safety

helped 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 trees

Jetpack 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 patterns

As 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
Flutter

Jetpack Compose was not just a new UI toolkit.

It was Android’s evolution toward a more reactive, state-driven, and modern UI architecture.

--

--

Tarun Gehani
Tarun Gehani

Written by Tarun Gehani

9+ years with Gradle fellow.