apersonwhoexistsmaybe
apersonwhoexistsmaybe
Schrodinger's Existence
1 post
Don't wanna be here? Send us removal request.
apersonwhoexistsmaybe · 7 months ago
Text
Jetpack Compose
(disclaimer: I'm learning about this for the first time and my explanations are aimed at beginners and to be taken with a grain of salt. Tbh I'm mostly writing the notes for myself!)
It's a declarative UI framework. What does that mean? Let's say you're trying to make a cake. The opposite approach, imperative programming would be like a recipe - mix all the ingredients, pour in a pan, and bake at a certain temperature for a certain number of minutes. Most programming languages use this approach. The declarative programming approach specifies what kind of cake you're making: it says "make a circular cake with 54 sprinkles, blue frosting." You see this programming paradigm with HTML also - it simply specifies what components are to be displayed instead of how to construct them step by step.
Composition: UI elements are coded in "Composables" which can be nested inside of each other. It's kind of like a boxes in other boxes. Think of a text messaging interface: in the messaging screen, there's a bunch of text bubbles, and in each text bubble, there's some text. In this case, the screen, the bubbles, and the text strings are like our boxes and can be composed inside of each other.
Recomposition: if our Composable needs to be changed, it simply recomputes the element rather than updating the same instance. This keeps with the declarative paradigm and is more efficient than other approaches. There's much more nuance to be said about this, but since this is a beginner lesson, I'll leave it at that.
0 notes