Question for CMP / JetBrains: is there any thinkin...
# compose
r
Question for CMP / JetBrains: is there any thinking happening around first-class native-rendering targets alongside Skia, i.e. the Compose runtime driving UIKit and the DOM rather than drawing everything directly? On iOS and web, the current CMP approach continues to have platform fidelity issues: every platform behaviour and every platform change has to be re-implemented and kept in sync forever. • Web: a lot of posts on #compose-web are about things that just work in the DOM: text selection, copy/paste, accessibility, SEO, etc. Compose-web apps have an uncanny valley -- generally, they just don’t feel right. • iOS: React Native already has Liquid Glass support, because it renders real platform views. In CMP we need third-party reimplementations like Kyant0’s Liquid Glass effect library for CMP (https://github.com/Kyant0/AndroidLiquidGlass/). 1.11 retrofits UITextInput-backed text fields which are native, but are still embedded in the Skia graphics layer — is the intent to do this native embedding one component at a time? Cash App’s Redwood showed a potentially workable model: shared state plus a design-system layer, with per-platform widget bindings instead of a lowest-common-denominator widget set. But it’s no longer maintained. This kind of system probably needs ecosystem-level ownership and direction-setting. AI changes the economics too: writing the per-platform bindings is now cheap, and even customizing design-systems per platform is relatively easy. But doing this while keeping the shared, human-directed and reviewed surface in one language and paradigm has no first-class path today in the Kotlin ecosystem, and I think it probably should.
🧵 1
👍 1
s
Giving wildly different UI toolkits a common api is hard; harder than just maintaining two UIs on a shared logic core. I think if you really care about native ui, it’s better to write the native ui in the platform’s idiomatic ui framework, and share viewmodels and logic underneath with KMP. You can also do a hybrid, for example high level navigation with the native liquid glass nav bar, but individual screens in compose’s skia.
☝🏻 1
o
Do you know why Redwood is no longer in active development?
j
There is compose html → I have used it, but it sadly comes with all the downsides of html, js and css, which is the state synchronization shitshow that that stuff represents. So no finegrain control over animation and drawing. Here you feel that if you want a higher performing application, you will somehow need to draw on a canvas so you control the actual rendering, hence compose for web that uses a canvas and wasm. The latter is now in Beta, the former I am not sure about its stability, but maybe now there will be more effort put into it as people found out maybe they can use it for server side rendering. Compose itself is a tree managing library, if you go back to the early days in the chat you can see discussions how jetpack compose should have been called (Jetpack) Compose UI. This means, that there are certain individuals (Jake Wharton) who indeed made it work for the Android View world. (and I see now that Redwood is the fruit of that labor). However, I do believe you are wrong that compose should simply wrap around a framework’s existing API. if you take out the rendering part, you are left with a pure tree manager and if you would compare the API from the compose HTML with the rest of it, you will see the difference. Yes you can reuse code between them, but you will lose all the fancy stuff. You lose all the magic that makes compose apps nice → either you have to reimplement all animations, transitions, special sizing and whatnot per platform, or just produce bland apps that may not behave nicely. On Android, the need for a new UI framework was immense as the View class grew to become a monster, the model of inheritence wasn’t managable anymore. So you cannot go back to make a simple widget library out of compose on Android → that ship has sunk by its own weight. Jetpack Compose is unimaginably better, going back to View would mean a kick in the face to every developer. That makes Compose not just a tree manager but also the rendering engine. To wrap all behaviors of all Android versions, iOS versions, browser versions and desktop versions behind widgets would be a massive undertaking → Will you take ownership of that? 🙂 I think it is a bit a lot to expect from a community or company. Then to have a proper rendering engine that interops with a platform is a much better alternative: google showed it with Fltuter it is quite good and performant. I think trying to make 1 piece of code run natively on every platform is a dream, you would have to have very strong defaults and hope that it stays supported, and customizability will probably go down the drain. However, with Compose you can mix and match → don’t like compose doing something? Well, drop in the platform specific solution. Or don’t use it if it doesn’t match your wishes. I would hate it if Compose would wrap around a default set of widgets. For web, this doesn’t even exist. For windows, mac or linux, how do you even imagine that? It would propose severe limitations. Your example with React is not great: React is not known for speed, and you cannot simply share the code between the platforms (between web and mobile/native), let alone run it on desktop (and from my short experience, react relies heavily on the abandoned hopes and dreams of 3rd party library creators.) In my opinion, the fidelity issues are simply the trade offs of not having to do it natively. You can do it natively, you can even do it partially natively, it is up to you. Web is still in beta, I believe it will get better. I am now making my first proper app, and I do like it more and more. The performance is great, and lately it runs good on desktop and mobile browsers. Apples liquid crap was a slap in the face for all different frameworks, compose multiplatform at least lets you render these native components on top of your app if you choose so. Luckily there is also the Haze library. Or you can just render the

native toolbar▾

☝🏻 1
➕ 2
r
@Oleksandr Karpovich [JB] No idea why Redwood is no longer in active development. @Sargun Vohra You say: > Giving wildly different UI toolkits a common api is hard; harder than just maintaining two UIs on a shared logic core. I don’t disagree its hard, but its also why such a thing available at the ecosystem level would be valuable. React Native shows it can be done. I’m also not talking about exposing everything via a common API necessarily. The trick (and benefit) for a theoretical lets call it “CNMP” (Compose Native Multiplatform) would be extract a common API where it makes sense, and expose non-common platform specific functionality through platform specific libraries and expect actuals. @Joost Klitsie There are a lot of things in your post I disagree with and many where I don’t understand your point at all. Let me tackle a few: > There is compose html → I have used it, but it sadly comes with all the downsides of html, js and css, which is the state synchronization shitshow that that stuff represents I have built apps with Compose HTML and it works very well. HTML+CSS is declarative and very easy to drive elegantly from application state. Definitely not a shit-show. JS is what we’re replacing so its irrelevant in a green-field application, it has little to do with Compose HTML. > if you take out the rendering part, you are left with a pure tree manager Like you say, Compose is just a tree. The “render” part can be whatever we want. It can be drawing pixels on the screen via Skia or it can be “rendering” native components. Nobody was suggesting removing rendering, unless you meant it in the narrow technical sense of drawing pixels on the screen. For this use case, we’re still rendering UI — just native widgets instead of pixels. > To wrap all behaviors of all Android versions, iOS versions, browser versions and desktop versions behind widgets would be a massive undertaking → Will you take ownership of that? Its massive no matter which way you look at it: the current approach rebuilds (with < 100% fidelity) every native widget in Skia, and the approach I’m suggesting reuses the native widgets and exposes them via some API. I’d argue the latter is less massive in general and easier to maintain in the long run. Especially if the API is carefully designed and limited to the 80% of common use cases, ignoring the long tail of esoteric functionality (which the Skia re-implementations also ignore). That being said — I’m not even sure it is that massive, with AI tooling in the mix. > I think trying to make 1 piece of code run natively on every platform is a dream, you would have to have very strong defaults and hope that it stays supported, and customizability will probably go down the drain. I don’t see why. Kotlin’s expect-actuals provide an elegant way to leverage platform-specific capabilities from a common code-base. Again, React Native shows it can be done, and they don’t even have the advantages of Kotlin actually being able to use platform-specific code directly without using plugins for everything. > Your example with React is not great: React is not known for speed, and you cannot simply share the code between the platforms (between web and mobile/native), let alone run it on desktop (and from my short experience, react relies heavily on the abandoned hopes and dreams of 3rd party library creators.) I have no special love for React, but lets be honest — React Native is actually pretty nice, and at least for now is used by more devs than CMP. Its not “native” code, but it “renders” to native widgets, so its actually more “native” than CMP in the ways that matter to end users, on every platform except Android. @Filip Wiesner posted about it here: https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1787036850402289. Like Filip said in that thread, I’d prefer if we were able to do the same things as React Native within the Kotlin ecosystem.
s
React Native shows it can be done.
IMO that’s a great example as it’s done about as well as it can be, and is still not a great experience. that ecosystem tends to be years behind on “native” android stuff like M3 Expressive and predictive back. Most RN apps even today, even brand new RN apps, are still using pre-Compose Views and don’t support predictive back
Even if you build an abstraction layer over say, modern SwiftUI and Compose UI, you still need to consider platform-specific idioms at the layout and navigation level, beyond individual components, else you end up with either an app that doesn’t feel native despite using native components, or two UI trees on one framework anyway
r
> Most RN apps even today, even brand new RN apps, are still using pre-Compose Views and don’t support predictive back That’s not a problem exclusive to RN. Most native Android apps today don’t support it either. At least on my device I can count on one hand out of hundreds of apps the ones that do. That’s because it requires developer support, not just a technical solution. > Even if you build an abstraction layer over say, modern SwiftUI and Compose UI, you still need to consider platform-specific idioms at the layout and navigation level, beyond individual components, else you end up with either an app that doesn’t feel native despite using native components, or two UI trees on one framework anyway Sure, but I fail to see the point. This is true on CMP as we know it today as well. The point of CNMP is exactly to provide platform-specific behavior, using a common language. Today if you want true platform-specific behavior, you have to write your iOS UI code in Swift and your Android UI code in Compose.
s
That’s not a problem exclusive to RN
As recently as a few months ago, I ported an app from RN to Compose specifically because there was no api to support predictive back properly That’s very different from developers just choosing not to use the api. Brand new apps built on Compose tend to do it well, legacy / enterprise apps still tend to not
Sure, but I fail to see the point. This is true on CMP as we know it today as well. The point of CNMP is exactly to provide platform-specific behavior, using a common language. Today if you want true platform-specific behavior, you have to write your iOS UI code in Swift and your Android UI code in Compose.
The point is if you care deeply about platform ui idioms, you end up with two ui trees no matter the framework. “CNMP” doesn’t solve that problem If you don’t, or you have your own design system, you don’t need the complexity of an awkward abstraction layer over two ui frameworks. CMP solves that problem fairly well, as do flutter, avalonia, etc.
r
The point is if you care deeply about platform ui idioms, you end up with two ui trees no matter the framework. “CNMP” doesn’t solve that problem
I agree with this. There will always be those who want to write their iOS code in SwiftUI. That isn’t the use case for CNMP. What CNMP solves are similar use cases as CMP (as well as React Native), but it brings native UI widgets into the capability mix. Native widgets matter — platforms put a lot of time and effort building the interaction models for native widgets. That work should be leveraged rather than replicated.
If you don’t, or you have your own design system, you don’t need the complexity of an awkward abstraction layer over two ui frameworks. CMP solves that problem fairly well, as do flutter, avalonia, etc.
But it can be better. CMP on web attempts to replicate hundreds of thousands of lines of browser code. It will never do it perfectly. Same on iOS.
p
Internally we built a compose-swiftui runtime that builds a tree of Views using compose. It is modeled after expo's swiftui implementation. We have three different UIs, one for android compose, one for swiftui, and one for compose html. They're all compose but they are explicitly not shared, they do share compose presenters though
👍 1
r
Very interesting @Pearce Keesling — anything you can share / open source? I’d love to see it.
p
Sadly it is very tightly coupled to our codebase so there's nothing to open source. But if you investigate expo swiftui that's the main idea. We tried doing uikit but it is way more complex because layouts are really hard to get right unless you want to go all in (like how RN uses yoga)
r
That is at least a technical proofpoint. Thanks. Expo UI (Expo being the most popular platform based on React Native for those that don’t know) is really similar to what I wish Kotlin had within its official ecosystem: https://docs.expo.dev/versions/latest/sdk/ui/. You can choose Universal components that provide a common API over SwiftUI / Jetpack Compose components, or use the SwiftUI/Compose components directly for more platform-specific control. > Start with Universal when you want one component tree that runs unmodified on Android, iOS, and web. Reach for Jetpack Compose or SwiftUI directly when you need platform-specific controls, modifiers, or behavior that the universal API doesn’t cover. With the advantages of Compose and Kotlin’s language capabilities like expect/actual this approach would IMO be even better.
c
I hate to be that guy, but people are moving off ReactNative to KMP or Native platforms because LLMs have made it much easier to copy features between apps, the overhead of maintaining different code bases is way down now. That does imply you have tooling and harness setup to do that, but building 3 different platforms at the same time as the lowest barrier to entry ever (and its only getting easier…) I do agree that wasm and iOS feel “weird”. The graduation from that is native dev on those platform imo. Personally, I really like wasm - but it’s the one that needs the most support and gets the least - it will be the first to move off KMP as it lacks so many things that make it scalable. iOS IMO feels pretty native, and there are many libraries that will show iOS UI or Android UI based on platform so I really don’t feel like thats a blocker + Haze
r
@chrisjenx I generally agree, but fully native still requires humans with experience in multiple languages, and maintaining two separate code bases. AI has made that easier, but there is still a significant cost. Its manageable by larger orgs, but smaller ones will still want a single language and codebase for their cross-platform dev.
Also: none of this is a blocker. As others have said, its even possible to already do what I’m asking today via custom libs on iOS and Compose HTML. That isn’t the point of my post — the point is (ideally) to get people to reflect on the possibility of changing the direction of the entire Kotlin multiplatform ecosystem.
c
yeah, honestly I would prefer the web to be dom targets not a canvas
➕ 1
j
@rocketraman yeah I written down too much and it became a bit messy. The reason why there are so many frameworks on the web, is that HTML , CSS and JS all have their own internal state and it is a struggle to align everything (same as how it was/is with the Android View system, with styles, xml and whatnot). That is a shitshow in my book. Compose HTML is a great tool to make html sites with, but then still you suffer if you want to have nice animations, transitions and fancy positioning/sizing. You are also busy syncing state between Compose and the DOM rendering engine of the browser. Also, with rendering I mean actual rendering. As in drawing the shapes on a canvas, not just calling platform code. The latter is letting the platform render it for you. Compose Multiplatform solves its problems by letting you render whatever you want → sure that means if you want to have platform native behavior, you will not get it 100%, but you have 100% control over what you exactly are drawing and how it is exactly behavior. For Android this doesn’t matter, because on Android Compose is basically the native way to do it nowadays. “Its massive no matter which way you look at it: the current approach rebuilds (with < 100% fidelity) every native widget in Skia” → I don’t think so. You get basic buttons and text input and whatnot, but there is not a Windows specific button, there is not an iOS or MacOS specific button and there is no Web specific button build into the framework. We have very basic components, with behavior attached to it from Compose. So you have 1 implementation, not 5 or 6 different ones depending on what platform you are on. To actually have Cupertino style stuff, or Windows style stuff, or Linux style stuff, or web style (whatever that may be) stuff takes a lot of work to have custom button for every platform, drawn on the Compose canvas (for Android we luckily already have the Material library provided by Google, which is also fine to use on web). Then to wrap it like you said: use Compose pure as tree manager and not use the rendering enging (the Skia canvas it draws on) and make the OS render the buttons and whatnot based on the iOS/Android/web/whatever sdk → You will lose a lot of functionality. As said, you cannot position, animate, transition things properly. On top of that, you are back at synchronizing state (one of the BIGGEST problems Jetpack Compose originally solved) between Compose and the platform components, which is a pain and will be more work and lead to crappy behavior, hard to debug unwanted side effects. You are then at the mercy of the creator of these components → how can you have 1 API that can solve the problem on every differnet platform? Still leaves the question: who will maintain it? React Native doesn’t solve this. It only targets mobile so you lack other platforms. It also lacks in platform specials → support for new things usually comes late and if you want to do it yourself you have to write all the boilerplate code. If I would want to have native behavior and it would be my choice → I would make my app KMP foundation, have Compose for Android and SwiftUI for iOS on top of that. Here if you have an iOS and Android dev (and we forget the other platform exists 🙂 ) you at least have much less code to maintain, as the whole logic can be shared and only the UI is different. As other people said, you can even get an LLM to help you out here. The nice thing about Compose is → if you really want to have a mobile library that renders iOS components on iOS, and whatever you want on Android, you can make it 🙂 But on Android there is a good reason the View system is basically dead, I am happy we have compose taking over there. Final note: React native is a big step away from actual native behavior in my book. The facebook app is slightly off compared to native apps, what you feel when hitting buttons and seeing sheets slide in and whatnot. AirBnB also moved away for a reason. React Native in my book is not for having great apps, it is to have cheaper apps. Their approach is just not good enough to take over the world, and it is mainly used as a cost cutting tool.
r
> React Native doesn’t solve this. It only targets mobile so you lack other platforms. It also lacks in platform specials → support for new things usually comes late and if you want to do it yourself you have to write all the boilerplate code. Umm, not really. Like I mentioned above, Expo (which is the platform most people doing RN are using) has the exact analog: docs.expo.dev/versions/latest/sdk/ui. And yes, it can target web (DOM) too.
> If I would want to have native behavior and it would be my choice → I would make my app KMP foundation, have Compose for Android and SwiftUI for iOS on top of that. Here if you have an iOS and Android dev (and we forget the other platform exists 🙂 ) you at least have much less code to maintain, as the whole logic can be shared and only the UI is different. As other people said, you can even get an LLM to help you out here. @Joost Klitsie I appreciate the reply but most of what you are arguing has already been addressed above. I agree with this, but it’s still two codebases to maintain, AI assistance or not. Smaller orgs don’t want that when there are good alternatives. BTW, the Facebook app is not 100% react native, so its not a great example to show RN sucks.
s
BTW, the Facebook app is not 100% react native, so its not a great example to show RN sucks.
Interestingly, some of the worst bits of the FB app are the RN bits, like the fb marketplace areas but that’s not really RN’s fault; there’s good ui/ux out there with RN too. It’s a great fit for Facebook because they have their own design system
👍 1
j
But if you are passionate about it → why not write your own library? Maybe get some other people to help out. I think there is a high chance you can find a way to deal with it and make it behave as how you want it, and then maybe have AI generate the code for you (like if you instruct it how to define platform specific components, maybe it can help a lot with boilerplate generation). I did find that using AI to generate tooling is amazing: it can do the job I usually don’t have the time to automate properly, but with AI it can be done much faster and suddenly you do have time to orchestrate it 🙂
r
@Joost Klitsie I explained why here : https://kotlinlang.slack.com/archives/CJLTWPH7S/p1794421203072569?thread_ts=1794258031.329019&cid=CJLTWPH7S — a library someone builds is just going to be a niche tool used by a few people, and will likely become unsupported over time. None of this really matters unless the ecosystem moves in this direction as opposed to the render pixels approach CMP is taking now.