Lesson 5: What Is Jetpack Compose, and Why Are We Using It?
What Is Jetpack Compose, and Why Are We Using It?
Before we write code, it's worth understanding what Compose actually is and why this course uses it instead of the older XML-based UI system.
The old way: XML layouts
For years, Android UI was built by writing XML files describing your layout, then referencing pieces of it from Kotlin/Java code with findViewById(). It worked, but it meant maintaining two separate files (XML + code) that had to stay in sync manually, and UI logic was often scattered and hard to follow.
The new way: declarative UI in Kotlin
Compose lets you describe your UI directly in Kotlin — no XML, no findViewById(). You describe what the UI should look like for a given state, and Compose figures out how to update the screen when that state changes:
@Composable
fun Greeting(name: String) {
Text(text = "Hello, $name!")
}This single function is the UI — there's no separate layout file to keep in sync.
Why "declarative" matters
In the old system, you'd manually write code to update a text view when something changed: textView.text = newValue. In Compose, you just describe what the text should show based on the current state, and Compose automatically re-runs that description (called recomposition) whenever the underlying state changes. You'll see this concept properly in lesson 12 — for now, just know it's the core idea behind everything we build.
Is Compose actually used in production?
Yes — Compose is Google's official, recommended toolkit for new Android UI as of today, used across Google's own apps (Play Store, Drive) and the vast majority of the industry going forward. Learning XML layouts first is no longer necessary for a beginner in current-day Android development.
Next: Lesson 6 — writing your first real Composable function and running it.