An open source Kotlin framework for cross-platform applications, based on Jetpack Compose for Android, is now previewing.
Google’s Jetpack Compose is an official framework for building a user interface into an Android application, and reached version 1.0 last week, along with the first stable release of Android Studio, 2020.3.1 or “Arctic Fox”.
Although it only hit 1.0, Google noted: “There are already over 2,000 apps in the Play Store using Compose – in fact, the Play Store app itself uses Compose.”
Compose is a declarative framework that departs from the traditional Android approach of a hierarchy or tree of layouts and controls. A Compose user interface is defined by writing functions annotated with the @Composable annotation, which describe the state of the screen: the functions generate the user interface. âAs the state of the app changes, your UI automatically updates, which makes it much easier to build the UI quickly,â the Google Android team said.
Compose is a Kotlin framework, and Kotlin and Android Studio (the official Android IDE) come from developer tools company JetBrains. Although Jetpack Compose is only Android (unlike Google’s Flutter framework), JetBrains believed Compose could be cross-platform as well. Compose multiplatform is a port of the framework for macOS, Linux, Windows and Web. Version 1.0 Alpha has just been released. Although this is a first release, JetBrains told us that it “provides stable APIs that developers should already be able to use safely.”
We asked Nikolay Igotti, Head of Compose at JetBrains, why the company is investing in Compose for Desktop when it already has a cross-platform Java framework for desktop applications, used in its IDE IntelliJ IDEA and its many variations. âIt’s pretty much Swing with a few modifications,â Igotti said. âSwing is the default JDK UI framework, Swing and AWT (Abstract Windows Toolkit). Compose is a completely different framework, although we provide interoperabilityâ¦ Swing is a fairly old framework, released in the late 90s, since then people have changed the way they think about the user interface. “
Compose has one thing in common with Swing: it draws its own controls, unlike some cross-platform frameworks – Java’s SWT (Standard Widget Toolkit) or Microsoft’s Xamarin, for example – which use native controls. Compose uses the Skia open source graphics library, also used by Google Chrome, Flutter, and many other frameworks. Does this mean that a Compose app won’t look native? âIt’s up to the developer to decide how they thematize their application,â Igotti said. “It’s a similar situation to other frameworks like Flutter in this regard.”
Does a Compose for Desktop application depend on the JVM (Java Virtual Machine)? âWe realize that distributing a JVM application can be a bit tricky,â Igotti told us. “We have our own Gradle plugin and it uses jpackage and Jlink to build native applications from JVM applications. You get .dmg for Mac, MSI for Windows, .deb package for Linux, you don’t think about the JVM. Kotlin / Native compiler that avoids this. âIt will be used in the future or for desktop development,â Igotti said.
What about web applications? “We use the Kotlin / JS compiler, âIgotti said. The web version of Compose is not as advanced as the desktop version, and the documents warn that “the API is not finalized and significant changes can be expected.” template, the API is different and uses HTML and CSS, so less code can be shared with Compose for Desktop.
âComposing is a different way of thinking about apps,â Igotti said. âState is a source of truth for the user interface, and the user interface is stateless, it is always calculated from the state. In this regard, Compose [for web] shares the same set of primitives, state management is shared. If you’re talking about the exact set of widgets, the way they’re organized, it’s not shared, âIgotti said.
What is the main driver behind expanding Compose from Android to these other platforms? âCompose’s target audience is made up of three groups of people. The first is Android developers using Kotlin and Compose who want to deliver on other platforms. Another is from Kotlin developers who want to write new apps that ‘write once, run anywhere’. Third, people who are new to Kotlin or Compose but want to create an engaging user interface, we want to give them the tools to do it easily. “
Igotti didn’t want to commit to any dates, but said he hoped a beta release would be delivered “mid-fall” and “we’re hoping for a 1.0 this year”. The project is open source and “it’s a general attitude in the 21st century that people don’t charge for frameworks,” said Igotti, with the JetBrains business model based on tooling. âWe want to create missing software,â he said.
Note that Compose does not have a visual designer. âMost vendors want to move away from graphical user interface builders,â Igotti said, in favor of a declarative user interface and ways to preview that. “We provide a preview mechanism so that if you put some annotation on the composable feature, it can be previewed without running the app.”
JetBrains considers desktop application developers to be underserved, an opinion partly informed by the company’s own development surveys. “The office is like a second class citizen to a lot of people … it seems like a niche that needs some attention.”
Will JetBrains use Compose for its own tools? One of them, JetBrains Toolbox (which manages installed IDEs), already uses Compose, but Igotti said there is too much legacy to expect it to replace the existing framework for products. like IntelliJ IDEA. âThe most complex and important component is the editor, it’s been in development for 20 years and it’s very unlikely to be rewritten in the medium term. It’s not JetBrains or my goal to force everyone to write in Compose. Our goal is to give those who need a better framework a chance to use it. “
We took a quick look at Compose for Desktop using the IntelliJ IDEA Community Edition and the Basic Tutorial – it all seemed a bit cutting edge, but we managed to bring Hello World to the screen.
Does the world really need another cross-platform framework? Google’s Flutter, while primarily aimed at mobile, is now also targeting the desktop, as well as iOS, which Compose does not currently support. Flutter’s language is Dart, however, and while Dart usage is on the rise (mostly because of Flutter), it’s still less popular than Kotlin, according to the latest StackOverflow survey.
There is evidence of momentum, with over 5,000 stars for the GitHub repository and plenty of issues reported: Developers should expect a few hiccups but it’s a sign of activity. Compose has a distinctive approach to UI creation and perhaps the best way to look at it is that for those who prefer this model through its use for Android, the ability to target other platforms will be the one. Welcome. Â®