Kotlin: The Language
Kotlin is a modern, statically-typed programming language developed by JetBrains. Google declared it the preferred language for Android development in 2019, and as of 2026, it is the standard choice for new Android projects. Kotlin runs on the JVM and is fully interoperable with Java, meaning you can use existing Java libraries and gradually migrate Java codebases.
Why Kotlin Over Java
- Null safety: Nullable types are explicit. The compiler prevents null pointer exceptions at build time.
- Concise syntax: Data classes, extension functions, and type inference reduce boilerplate by 30-40% compared to Java.
- Coroutines: Built-in structured concurrency for async programming without callback hell.
- Sealed classes: Powerful pattern matching for state modeling.
- Interoperability: Call Java from Kotlin and vice versa without friction.
Kotlin Multiplatform (KMP)
Kotlin Multiplatform allows sharing business logic between Android, iOS, web, and desktop while keeping native UI. In 2026, KMP is stable and gaining adoption for shared networking, data, and domain layers across platforms.
Jetpack Compose: The UI Framework
Jetpack Compose is Android's modern declarative UI toolkit, officially stable since 2021. It replaces XML layouts with Kotlin-based UI code. Like SwiftUI on iOS, you describe what the UI should look like, and Compose handles rendering and updates.
How Compose Works
Compose uses a compiler plugin that transforms your @Composable functions into an efficient UI tree. When state changes, Compose only recomposes (re-renders) the parts of the UI that depend on that state. This is called smart recomposition.
Core Concepts
- @Composable functions: Building blocks of UI. Any function annotated with @Composable can emit UI.
- State: Use remember and mutableStateOf to hold state within a composable. Use rememberSaveable to survive configuration changes.
- Modifiers: Chain visual and behavioral modifications (padding, size, click, scroll) on any composable.
- Layouts: Column, Row, Box, and LazyColumn/LazyRow for scrollable lists.
- Material 3: The default design system with built-in themes, components, and dynamic color support.
Compose vs. XML Views
| Aspect | Jetpack Compose | XML Views |
|---|---|---|
| Style | Declarative (Kotlin) | Imperative (XML + Java/Kotlin) |
| Preview | @Preview annotation | Layout editor |
| State handling | Reactive, automatic | Manual view binding |
| Themes | MaterialTheme composable | styles.xml + themes.xml |
| Animation | Built-in animation APIs | ObjectAnimator, MotionLayout |
| Maturity | Modern, evolving | Fully mature, 15+ years |
In 2026, Compose is production-ready and recommended by Google for all new Android projects. The XML view system is in maintenance mode with no major new features planned.
Architecture
Google recommends a layered architecture for Compose apps:
UI Layer
- Composable functions that render the screen
- ViewModel holds UI state and handles user actions
- UiState pattern: a data class representing everything the UI needs to display
Domain Layer (Optional)
- Use cases that encapsulate business logic
- Useful for complex apps, optional for simple ones
Data Layer
- Repositories abstract data sources
- Data sources handle network calls (Retrofit/Ktor), local database (Room), or DataStore
Key Libraries
- Hilt: Dependency injection (recommended by Google)
- Room: SQLite database with coroutine support
- Retrofit / Ktor: HTTP networking
- Coil: Image loading optimized for Compose
- Navigation Compose: Type-safe navigation between screens
State Management
Compose provides several state patterns:
- remember + mutableStateOf: Local composable state
- ViewModel + StateFlow: Screen-level state that survives configuration changes
- rememberSaveable: State that survives process death
- CompositionLocal: Implicit state passing through the composition tree
The recommended pattern is unidirectional data flow: state flows down from ViewModel to composables, and events flow up from composables to ViewModel.
Performance
Compose performs well by default, but keep these tips in mind:
- Use LazyColumn/LazyRow for lists (not Column inside a verticalScroll)
- Provide stable keys for list items
- Avoid unnecessary allocations in @Composable functions
- Use derivedStateOf to prevent unnecessary recompositions
- Profile with Android Studio Layout Inspector and composition tracing
When to Choose Kotlin/Compose
Kotlin and Compose are ideal when:
- You are building an Android-only app or Android is your primary platform
- You want first-class support for the latest Android features (widgets, foldables, Wear OS)
- Performance and native feel are priorities
- Your team prefers strong typing and modern language features
Consider cross-platform frameworks if you need iOS support and want to maximize code sharing.