What is Jetpack Compose and how does it differ from the View system?
Jetpack Compose is Android's declarative UI toolkit. You describe what the UI should look like for a given state, and the framework updates it when the state changes.
The differences from Views:
- Declarative versus imperative. With Views you find a widget and mutate it —
textView.text = name. With Compose you write a function of state, and recomposition handles updating. This removes a whole class of bug where the UI and the underlying state drift apart. - No XML. Layouts are Kotlin, so you get type safety, loops, conditionals, and normal refactoring tools.
- Composition over inheritance. Reuse comes from small composable functions rather than subclassing View.
- State is explicit.
rememberholds state across recompositions;rememberSaveablealso survives configuration changes and process death.
Recomposition is the key concept: when state a composable reads changes, Compose re-runs that function. It is intelligent — only affected composables re-run — but composables must therefore be side-effect free and cheap, since they may run often and in any order. Side effects belong in LaunchedEffect, DisposableEffect, or similar.
Note: Two practical points. Compose and Views interoperate, so migration can be incremental via ComposeView and AndroidView. And state hoisting — moving state up so a composable takes state and a callback rather than owning it — is the pattern that makes composables reusable and testable.





