I am currently building the project in kotlin +XML...
# android
p
I am currently building the project in kotlin +XML is this good or I want to move to the jetcompose guide me guys
p
Move to Compose, no reason to use XML in 2025
💯 8
👍 2
p
Any particular reason or any advantages there? please detail that I want to know why it is best.
p
Jetpack Compose is recommended by Google, it's status quo and being actively developed. XML is much worse as far as UI performance goes, updating UI in Compose is easier imo. Also it's way faster to develop UI in Compose in my opinion. I don't know, the question is weird, it's like asking why I would want to use Kotlin instead of Java 😄
g
@Pavel Habžanský look at /r/AndroidDev, you get that Kotlin vs Java question a lot
t
I recently had to stop trying to contribute to the AntennaPod repo because the two main guys maintaining it refuse to move away from Java because they “don’t have time to learn Kotlin”.. 🤦🏻 one of them has a PhD - even ostensibly intelligent people don’t understand, so it’s fair to ask.
😀 1
@prasanna Since the XML system requires imperative implementations, it’s fairly easy to miss a piece of state when updating your UI, and one of the best ways to avoid inconsistent updates is to use a pattern where you maintain one (or more) object(s) that represents the UIs current state (historically called a View Model before Android appropriated the term as a system component). Updates in the domain layer could only make their way to the UI through UI state objects, which in theory required the entire UI to be consistent across all updates. (In practice you could implement it poorly and start treating the state object like the UI itself, creating inconsistent updates which then still allow bugs in UI even though technically the UI is consistent with the state object…) In XML, if we’re all using this ViewModel/UIState pattern, that means every single developer/team is putting in work to re-implement essentially the same binding logic imperatively. Compose does away with that distributed redundancy by providing us with a declarative framework that only cares about the end-state. The compose compiler/engine figures out how to move from one state to another, so we’re not all rewriting that same logic anymore. Instead we just need to worry about the models that are specific to our application, reducing complexity AND effort. Of course it isn’t without it’s own overhead, and most people have trouble when they get started with animations or transitions, but even that is easier to learn and apply than it was in the old XML system. And optimization is a whole other level, but even without careful optimization, Compose is highly performant. The Android Code Labs are excellent to start with if you have trouble getting through documentation. It’s too easy. Get started NOW: https://developer.android.com/codelabs/jetpack-compose-basics#0
❤️ 4