Jetpack Compose
Declarative UI, recomposition, remember/state, and side-effect handlers (LaunchedEffect). Understanding what triggers recomposition is the performance question here.
The mental model
Imagine a spreadsheet. You do not tell a cell "erase yourself and redraw as 42" — you write a **formula** that says = A1 + A2, and whenever A1 or A2 changes, the cell recomputes itself. You describe the *relationship* between inputs and output once, and the spreadsheet keeps the display in sync. **Jetpack Compose is a spreadsheet for your UI.** A composable function is a formula: given some state, it describes what the screen should look like. When the state changes, Compose re-runs the affected formulas and updates the screen. You never imperatively textView.setText(...); you declare "this text is state.name", and Compose handles the rest.
That re-running is called recomposition, and it is the single concept that explains almost everything about Compose performance and correctness. The old (View) world was imperative: you held references to widgets and mutated them, and bugs came from the UI and the data drifting out of sync. Compose is declarative: the UI is a function of state, so it cannot drift — but the cost is that Compose must know what to re-run when. It tracks which composables read which pieces of state, and when a state object changes, it re-executes exactly the composables that read it. Read the wrong thing, or make state Compose can't track, and you either re-run too much (jank) or too little (stale UI).
The reason this matters for interviews: the performance question in Compose is always **"what triggers recomposition, and how do you keep it small?"** A candidate who thinks Compose "just redraws the screen" will write code that recomposes a 500-row list on every keystroke. A candidate who understands that Compose recomposes only the composables that *read the changed state* — and that remember, keys, and stable types control that — writes UIs that stay smooth on a budget phone.
The unifying idea: a composable is not a thing you build once and mutate; it is a description Compose re-evaluates whenever its inputs change. Your job is to make those inputs precise, so recomposition is cheap and scoped.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision