Declarative UI: How SwiftUI, UIKit, and Compose Build Mobile Apps

Declarative UI: How SwiftUI, UIKit, and Compose Build Mobile Apps

blog post publisher

Vica Cotoarba

Head of Mobile Development

Reading time: 4 min

Updated: Jul 2, 2026

Key takeaways

  • Declarative programming describes what the UI should look like, while imperative programming spells out every step to build it.
  • SwiftUI (2019, iOS 13) is Apple's declarative framework; UIKit is the older imperative one that has existed since iOS 2.
  • Declarative UI code is shorter, enforces a single source of truth, and makes components easy to reuse.
  • Jetpack Compose is now stable and the recommended standard for new Android UI; React Native and Flutter are also declarative and state-driven.
  • The core idea is UI = f(state): change the state and the framework redraws the interface for you.
Mobile-Development
Declarative-UI
Swift-UI
UIkit

Mobile apps are here to stay, and that has led to a steady stream of new frameworks and tools for building them. Today we focus on the UI side, because a real paradigm shift is happening in how we build app interfaces.

That shift moves us from imperative programming to declarative programming. Before we dive in, let us define what declarative UI actually means.

What is declarative programming?

Declarative programming is a paradigm that describes the desired end result and how it should look. It does not list every execution step. In short, it expresses the outcome, not the control flow.

The more familiar imperative paradigm does the opposite. It spells out a step-by-step path to the result, with instructions that keep changing the program state.

Enough theory. Let us look at some examples.

A simple example

Here is a cute comparison:

    • Imperative is like writing a recipe with step-by-step instructions: mix 100g of flour with two eggs, then stir the mix, and so on.
    • Declarative is like naming the dish you want: chocolate muffins.

Again, it comes down to how versus what.

SwiftUI vs UIKit: how versus what

One of the clearest comparisons is SwiftUI vs UIKit, since both live on iOS. UIKit is the traditional, well-established framework. SwiftUI is the newer approach with a different style.

Let us build the same custom screen with each one. We will use a simple confirmation screen from our app Raindrops.

Confirmation screen from the Raindrops app used to compare UIKit and SwiftUI

First, let us see the UIKit approach, taking the programmatic way without Xibs or a Storyboard.

UIKit code sample

UIKit code sample creating the confirmation screen imperatively with manual layout constraints

The imperative approach creates an instance for each UI element and mutates it until the design is right. Then you add all the layout constraints by hand.

Now it is time for the SwiftUI version.

SwiftUI code sample

SwiftUI code sample building the same confirmation screen declaratively with far less code

The declarative approach states a blueprint up front with all the setup it needs. You do not start from base instances and mutate them.

That does not mean the UI cannot change. When you update an element, the framework redraws everything to match the new blueprint.

The SwiftUI example needs far less code. Let us look at them side by side.

UIKit code for the confirmation screen shown side by side, the longer imperative version

SwiftUI code for the confirmation screen shown side by side, the shorter declarative version

SwiftUI shipped in 2019 with iOS 13, while UIKit has been around since iOS 2. Newer does not always mean better, but the declarative style brings clear advantages:

    • The syntax is shorter and cleaner, so you build faster.
    • You cannot change the UI from many places, since each component has a single source of truth.
    • UI elements are easy to reuse and compose. Maybe that is why Google named its framework Jetpack Compose.

Changing how you write code is hard. But when did anything great come easy?

What about other platforms?

A few paragraphs above, you saw a shy reference to Jetpack Compose. It is Google’s counterpart to SwiftUI, built on Kotlin.

Jetpack Compose is now stable and the recommended standard for new Android UI. Google’s own sample apps, architecture guides, and new libraries are Compose-first, so it is a safe choice for new projects. On iOS, SwiftUI has matured into a solid default for many apps too, though plenty of teams still mix in UIKit where it helps.

This article would not be complete without React Native and Flutter, two of the most popular cross-platform frameworks. Both started with a declarative, state-driven UI approach.

Diagram of the declarative UI formula, where the UI is a function of the app state

Image source: Flutter.dev

A simple formula captures the idea: UI = f(state), where f is the build method. Change the state, for example by flipping a switch, and the UI redraws based on f and the new state. Since these frameworks have no imperative alternative, we will not share more code examples here.

Declarative UI takeaways

Declarative programming is here to stay. Apple and Google set the trends in mobile app development, since they own the leading operating systems. Both invest heavily in declarative UI frameworks, so their direction is clear. The community will decide in the end, but these tools are off to a strong start.

About the author:

Dan is the Head of Mobile Development at Wolfpack Digital and aims to bring value to the world in areas like programming, fitness, and personal development. Dan likes to push technologies to the limits and to create exciting products that change people’s lives for the better but are also beautiful in their own way. He is a very competitive person who loves challenges and contests, taking them in various fields like mathematics, tennis, or even driving. Besides this, he believes that people can actually love what they do, or do what they love, and that we can enjoy life in a productive way too.

Frequently asked questions

Declarative UI is an approach where you describe what the interface should look like for a given state, and the framework handles rendering and updates. It follows the pattern UI = f(state), so changing the state redraws the UI automatically.
Imperative programming lists step-by-step instructions that change the program state to reach a result. Declarative programming describes the desired outcome instead, leaving the how to the framework. Building UIs declaratively usually means less code and fewer bugs.
SwiftUI is Apple's modern declarative framework and a strong default for many new iOS apps. UIKit is older, imperative, and still widely used for fine-grained control or legacy code. Many teams mix both, using UIKit where SwiftUI is not yet a good fit.
Yes. Jetpack Compose is stable and is now Google's recommended standard for building new Android UI. Google's own sample apps and libraries are Compose-first.
SwiftUI on iOS, Jetpack Compose on Android, and the cross-platform frameworks React Native and Flutter all use a declarative, state-driven UI model.
Vica Cotoarba

Written by

Vica Cotoarba

Head of Mobile Development

Vica is the Head of Mobile at Wolfpack Digital, leading the mobile development team in building high-performance iOS and Android applications that combine technical excellence with exceptional user experiences. With both a Bachelor's and Master's degree in Computer Science and over a decade of specialized experience in iOS development, she brings deep technical expertise and innovative thinking to mobile product development.


Her technical journey spans cutting-edge mobile technologies including Augmented Reality, Machine Learning integration, and scalable app architecture. Vica's approach to mobile development is defined by an unwavering commitment to clean, maintainable code and architectural patterns that support long-term product evolution. She understands that great mobile apps require more than just feature delivery—they demand careful attention to performance optimization, security, offline functionality, and seamless user experiences across devices.


As a mobile technology leader, Vica is known for her sharp eye for detail and unshakable persistence in solving complex technical challenges. She leads her team with clarity and high standards, fostering a culture of technical excellence while pushing the boundaries of what's possible in mobile development. Her leadership ensures that every mobile product Wolfpack Digital delivers is robust, scalable, and genuinely user-focused.


Vica's expertise has contributed to mobile applications serving millions of users, earning AppStore features and consistently high user ratings. She stays at the forefront of mobile innovation, exploring emerging technologies like SwiftUI, Kotlin Multiplatform, AR/VR frameworks, and on-device machine learning to deliver next-generation mobile experiences.


Through her blog contributions, Vica shares insights on iOS and Android development best practices, mobile architecture patterns, integrating AI and AR capabilities, performance optimization techniques, and building effective mobile development teams. Her writing reflects hands-on experience delivering award-winning mobile products across diverse industries.


Areas of expertise: iOS development, mobile app architecture, Augmented Reality (AR), Machine Learning integration, Swift and Kotlin, cross-platform development, mobile UX optimization, team leadership, code quality and maintainability, mobile security, performance optimization.

View profile