Jetpack Compose is a WIP new Kotlin-only UI toolkit that Google is developing for Android first. It was announced at Google I/O 2019.
As you can see, it’s called Jetpack Compose, not AndroidX Compose, so this is one of the clear signs multiplatform support is planned. I read several members of the team confirming it explicitly, and you can already see in the sources that the code is decoupled from Android, with Canvas being abstracted away for example.
One of the first things I noticed in
@Composable annotated functions is that they don’t return what they are composing (no return type is specified, so it defaults to
Unit). This led me to think that it may do allocations sparingly for performance reasons. After a discussion with one of the team members, I got confirmation, and what happens is that a mutable tree for the components to be drawn is passed instead, so no allocation for what didn’t change.
The way it works is similar to how functions with the
suspend modifier pass a
Continuation (done by kotlinc), but here, it is made by a compiler plugin wrote specifically for Jetpack Compose, which changes how
@Composable annotated functions are compiled.
I’ve read (from Roman Elizarov IIRC) that it was likely that the compiler plugin for Jetpack Compose could be made quite generic to allow new use cases with similar techniques.
So, that brings several questions regarding Data2viz (numbered for easy referencing), especially considering the performance struggles with frequent allocations that the current implementation (as of early May of 2019) suffers from.
Could Data2viz eventually rely on Jetpack Compose entirely? If so, that would imply a straightforward integration with all the platforms that are supported by Jetpack Compose, whether officially or not.
If not, could a similar compiler plugin be used to allow under the hood performance optimizations where allocation would be reduced to a minimum thanks to compiler and implementation code solely controlling mutation?
Do you think Jetpack Compose could be a Data2viz competitor, or make it easy for competitors to arise? If so, why? If not, why not?