Thought this note from another thread may be of in...
# multiplatform
d
Thought this note from another thread may be of interest: We're starting to use Kotlin Multiplatform on an Android-only project at work. Is anyone else doing this with a single platform project? It just feels like a good insurance policy to stay as loosely-coupled to the platform as possible; since KMP and the increasingly number of KMP libraries makes it so easy!
j
d
Oh nice! I think we have a good handle on it but this is really interesting TY
j
@John O'Reilly Wow nice, have missed that plugin! Thanks! πŸ™‚
@darkmoon_uk If only using Android and not intend to do anything, I mean sure you could prepare Gradle, Kotlin setup and such to can switch into Compose and/or Kotlin multiplatform, but in reality no real difference if only apply Android. However its quite nice as some androidx libs using KMP, so Gradle will evaluate those automatic for you instead of have to use like libs-android on all libs all the time πŸ˜› I think its always good to decouple code from SDK specifics. Like avoid using androidx lifecycle and Context in Compose if thats what you using, will help prepare but also improve your code even in native Android imo. Thats one thing I like as well, KMP pushing you re-think architecture and almost enforce using good DI and interface hexagonal structure kind a πŸ˜› It makes code in my opinion much better and flexible. It also protected yourself from easy being able to switch frameworks over time. Its very easy to enable one target at the time btw, if want to test wasmJs, js, desktop, iOS or such but not sure if works good or not. Its a very nice Gradle mechanism. And if you using Gradle convention plugins its even easier if having many Gradle modules, can apply everything for all modules in one place πŸ™‚
πŸ’― 1
πŸ‘ 1
d
Yes, we already strictly adhere to clean architecture, most of the code is easy to transition - pulling out the Dagger is the only painful part, I recommend medical assistance for that.
j
Hahaha using annotation based frameworks is always a pain in that sense πŸ˜„ I remember somewhat pain migrate from Glide to Coil when compose was new πŸ˜„ Or migrate from ButterKnife to Databinding when Kotlin was new. Or from RxJava/RxKotlin to Coroutines πŸ˜„
d
We're in favour of Manual DI; we have a convention that's based only in Kotlin language and is much simpler to work with.
βž• 1
j
Once going Kotlin and Kotlinx my life been easy in architecture speaking and migrate over time, such as KMP things πŸ˜„
d
We used our manual DI pattern in an earlier Kotlin Multiplatform project of ours and there was not a single point during the year where anyone said "Gee this would have been easier with Dagger". Mostly, we just stopped thinking about DI at all - and that's the point.
j
Its a two edges sword, its nice having Dagger annoations to have compile time safety, but also not nice using Kapt or Java annoations πŸ˜„ But using manual DI having circular deps or missing deps its much more painful if accidentially push to production and the entire app crashes πŸ˜„ To have a balance in KMP I recommend checkout eitehr Kotlin Inject or Koin for DI instead of manual, if want a middle thing πŸ™‚
d
Our pattern is compile-time safe.
j
Cool, compile time safe as checking circular deps? πŸ™‚
d
No magic, just constructor parameters and
object
Modules, with a few extra tenets thrown in.
j
Right, yeah with compile time safe I meant check the DI graph is satisfied and cant in runtime cause crashes.
d
Even if that possibility is open, I'd rather deal with 'one more runtime bug', than what I consider the hell of annotation DI.
😁 1
It's not like it's a more bug prone area of architecture than anything else.
j
Can also add that Jetbrains target group right now is Android apps want to try KMP/CMP, or Android devs kind a. So very easy take evetything you know in Gradle and JVM/Kotlin world and apply. Even Compose working in most cases out of the box. I am right now evaluating target wasmJs and desktop, on top of Android and IOS I have now. Working really good. Can use things like androidx collection, androidx datastore and Google working on androidx lifecycle KMP supported, which required to make the rest of androidx same πŸ˜„ Something tells me Google working on using KMP much more themselves.
d
Yep, it's an incredibly powerful ecosystem already, and growing stronger. I actually think people are underestimating the potential of Compose/WASM as a way of developing for the browser just like 'another rich client'. I lost my tiny mind when I realised the potential.
One Dev can target all channels.
j
If want web support, like wasm I recommend wait however, as not many libraries supporting wasm yet, only some of them having alpha released with support for that. Mostly its desktop/jvm and Android. And in some cases iOS. I looking forward having Auto, Wearables, TV for Apple and Android things soon πŸ˜„
Imagine using KMP to support all Android platforms with one CMP codebase πŸ˜„
d
Heh, I'm no stranger to the bleeding edge in that regard - JB Dev repo definitions all over the place in personal projects lol
j
Wasm is however quite buggy in browser Safari and Edge, for Wasm Canvas APIs etc that is. But its working in most browsers. Using my own design system in compose in all platforms right now πŸ˜„
d
I'm building a personal project in the expectation that by the time I finish it, those browsers will have 'caught up'
and if they don't... well let's just say it won't keep me awake at night.
j
I do see potential in merge Jetbrains things with AOSP repo, so we can get faster iteration of KMP and Compose things. That including androidx wearable and tv compose libs and also Glade. So can have adaptive compose layout components working in any platform. In end working in Apple TV as well πŸ˜„
d
Yes.
j
Ofc need to adapt into watches with circular screen πŸ˜„
d
Just yesterday I went on an AI journey to know if I could run Java Swing only on a linux FrameBuffer driver without heavy Windowing.
Because Compose for Desktop ultimately sits on Swing AFAIK (through Skia/JVM)
It might be possible to put Compose on the SPI LCD screens you typically get on Rapberry Pi
Or other small ARM embedded systems
No real reason, it would just be cool to put Compose there.
j
I remember these discussions from React Native and Flutter, everyone said Javascript working everywhere when worked on RPi and embedded things, but still no cigarr πŸ˜„ So I hope compose staying decoupled as its now, and not lock itself to much to support everything in same system, more a modular system with interop they doing now. Otherwise we will see fragmentation Xamarin style all over the place again πŸ˜„
Compose fingerprint engines needed often quite large, like render on Canvas things like Skiko.
We will see, but at current state I am optimistic at least supporting desktop, iOS and Android. For web I am not sure to be honest, but we will see. Dont like we have to depend on browser engines. Rather just use the OS browser running on like in desktop I think, if browsers could open up that instead would be easier πŸ˜› Like render window directly from OS rendering engine inside browser, if thats possible, dont know.
Anyway prepare for KMP is a good choice I think, so can easy switch in the future πŸ™‚
j
@darkmoon_uk I love your "Android-only, but KMP, to be prepared" approach. If you decide to release on iOS one day, we have a proprietary SDK that implements the Android API for lifecycle, widgets, layouts, etc. on iOS. Please DM me if you are interested in specifics, would be happy to talk.
m
@darkmoon_uk Could you provide a few more details of your β€œmanual DI pattern”?
βž• 1
e
@darkmoon_uk I am also interested in more details about β€œmanual DI pattern”. Could you please share some example?