Declarative User Inter­faces

It’s already been a while since a colleague of mine enthusiastically told me about Jetpack Compose. He used sentences like “This will change everything in Android programming.” And “It is already so great (in alpha state), can’t wait to see it in production.”

Will it stick – or: should I care?

To be honest, I really appreciate him as a developer and person. But he is kind of a nerd. So, I did not listen as carefully as I should have back then. Why should I care? Yet another way of doing things in Android ... seems like Android reinvents itself roughly every two years. Well, kudos to Paul: you were right. This is the next big thing and not just for Android. Here’s why.

What is it now, again?

To those who haven’t heard of it, yet, let’s briefly elaborate what Jetpack Compose actually is. It’s a method of implementing your UI in a declarative way. You no longer need to write layout XML files and view classes. With Jetpack Compose this comes all together – directly in your codebase. You use Kotlin as a language to describe (declare/compose) your UI – all broken down into small digestible components.

Hmm... does this sound familiar to you? Happen to be an iOS or React developer? Or cross-platform with Xamarin, Flutter? Or even QML? Basically, all the big players in modern programming technologies have already started the transition to declarative UI – for good reasons.

But before we continue with our topic of UI development, let’s take a step back and have a closer look at the differ­ ences between declarative and imperative programming to get the full picture.

Declarative vs. imperative programming

Think about your favorite programming language which you probably use on a daily basis. Does it support declarative or imperative programming? Have you ever thought about it? Probably not. The answer is pretty surprising: Most modern languages equally support both! Imperative and declarative programming are pro­ gramming paradigms – they do not rule out each other. But of course, they are not the same. So, let’s have a look at the differences.

Here’s a simple example. We want to calculate the sum of a list of numbers. The following code snippet demon­ strates how to imperatively implement sum in TypeScript.

Curious? Read more now.

Here you can download the complete UXMA Trend Report 2022 free of charge and benefit from other exciting articles!

Consent necessary

In order to use this feature, your consent to use our Hubspot services is necessary.
On this basis, we analyze website visits to create sales-relevant information.

Insights

Ready to start something big together?