Introducing Jetpack Compose for Desktop
Written by Nikos Vaggalis   
Tuesday, 10 November 2020

JetBrain's Jetpack Compose for Desktop is an open source project being developed in collaboration with Google’s Jetpack Compose, intended to simplify and accelerates UI development for desktop applications, and allow extensive UI code sharing between Android and desktop applications. It's first milestone release is now available. 

Is a 100% shared codebase between different platforms a futile dream? Many have tried to cross boundaries with a framework that can bridge multiple platforms, that is write your code once and let it run seamlessly on macOS, Linux, Windows, and iOS.
But, if even Microsoft can't unify the UI framework of its Windows platform, what can you expect from attempting to go across platforms?

Enter Jetpack Compose Google's answer to the multi-platform quest. Underpinned by the ubiquitous JVM, it is compatible with, and able to use, Java graphics APIs like Swing and AWT and running with Kotlin.

Jetpack Compose was originally deployed on Android as part of Google's Architecture Components, an attempt to clean up and freshen up the ways of developing for Android. Subsequently it has established itself as the new and default way of building GUI apps on the platform.This clean-up attempt didn't come without churn though, as we've described in Android Jetpack Compose Is Welcome, But What About The Churn?.

Mark Murphy of the well-known CommonsWare Consulting with many educational courses and books under his belt elaborated on the article in Issue #31 of his newsletter. I highly recommend going through the full commentary but here's a sample:

The “what about the churn?” post demonstrates a not-too-surprising reaction to Compose. New Android development technologies get hyped relentlessly, from Gradle to the Architecture Components to Kotlin to MotionLayout and now to Compose.

This very newsletter contributes to that hype. Usually, the technologies being hyped are positive developments, solving key problems in Android app development. Many thought leaders in Android rapidly latch onto how these technologies solve problems and, as a result of their enthusiasm, feed the hype engine.

In short, for Compose, or any new technology to succeed, there needs to be a state of progressive migration and help from the community.

With Jetpack being associated with the vast Android community, there should be the resources that are going to make it easy to learn and use it on other platforms too. That, in other words, means you can follow the ample Android tutorials found everywhere and use that knowledge on building app for other platforms too!

It is promised that you can share knowledge as well as large portions of UI code written for Android on, say Windows, without hassle.

For example on Android you can write composable functions that

let you define your app's UI programmatically by describing its shape and data dependencies, rather than focusing on the process of the UI's construction.To create a composable function, just add the @Composable annotation to the function name.

You can now do that on Windows too.

Of course, since the platforms are different you can't abstract everything. At one point or another you need to go platform specific, and as far as Kotlin is concerned Jetpack Compose Desktop caters for this case by exposing the relevant APIs of the underlying platforms. An open source project from JetBrain, Jetpack Compose for Desktop is being developed in collaboration with Google’s Jetpack Compose, ensuring that the two technologies will evolve together.

Code sharing  happens via Kotlin Multiplatform (KMM), an SDK for cross-platform mobile development provided by JetBrains. Check how Netflix is making use of it:

to write platform agnostic business logic once in Kotlin and compiling to a Kotlin library for Android and a native Universal Framework for iOS via Kotlin/Native

in this post on the Netflix blog.

It seems that Kotlin Multiplatform has now been extended to support other non mobile platforms too. To prove the point, the Jetpack Compose Desktop gradle plugin shipping with the milestone release can create installers for all the platforms:.exe,.msi on Windows, .dmg,.pkg on MacOS and .deb, .rpm on Linux.

It's important to note that this is Alpha material so some glitches are expected. What I do like the most though, is that JetBrains has opened its arms to embrace all developers by expecting their feedback to make their work better.

In short, Jetpack Compose Desktop is motivating the community, making code and knowledge reusing possible and, by basing it on Kotlin, a post modern language with bells and whistles, as well as first class compatibility with the vast Java library ecosystem and the JVM, it looks certain to shake up the way we do things across platforms.


More Information

Compose for Desktop - main page

Github repo

Netflix Android and iOS Studio Apps — now powered by Kotlin Multiplatform.

Related Articles

Android Jetpack Compose Is Welcome, But What About The Churn?

Introducing The Android Kotlin Developer Nanodegree

Why Do Android Devs Convert To Kotlin?

Focus On JetBrains Kotlin 1.4


To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


Learn Cryptography Without The Math

Are you sick of the math associated with cryptography?
You don't have to be any more. Applied Cryptography from the University of Tartu shows cryptography without the math! At last, a hands-o [ ... ]

Apache NiFi Adds Python Processor Support

Apache NiFi 2, a project for processing and distributing data, has been released with support for Python processors in the MiNiFi framework, and a completely rebuilt user interface.

More News

kotlin book



or email your comment to:

Last Updated ( Wednesday, 11 November 2020 )