https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
b

Ben Edwards

08/22/2022, 10:24 AM
TLDR: Advice on learning Kotlin for KMM. Hi, just starting my Kotlin journey. I did a couple of weeks doing basic Kotlin tutorials now I'm doing the doing udemy 'Android App Development Masterclass using Kotlin' . My ultimate aim is to develop multiplatform mobile apps (KMM). Thought doing Android apps first was a good approach. I have been programming for over 20 years, mainly using Oracle PL/SQL, quite a bit of bash, and some Ruby, and spend 80 days learning Python (udemy .100 Days of Code: The Complete Python Pro Bootcamp for 2022'). I'm fairly committed and planning on doing 6 hours a day Monday-Friday at least. So my questions are, is this a good approach, and any advice? Also what state is KMM in? It won't be 3 to 6 months before start developing in anger.
l

Lukasz Kalnik

08/22/2022, 8:39 PM
I don't know what Android UI framework is taught in this udemy course, but it's worth to start learning Jetpack Compose. Official Google samples are quite good already and there is a lot of tutorials. Regarding KMM, there is unfortunately as many approaches as there are developers, as currently the whole ecosystem is a bit fluid. So you get samples from "shared logic only" through "shared ViewModels" to even "iOS UI in Compose" (latest development of the DroidCon NYC app from Touchlab). Here are some samples you can take a look at.
m

Matti MK

08/23/2022, 6:36 AM
From the top of my head KMM and Android is pretty similar to standard modern Android development. You’ll be able transition much of what you’d learn from modern, up-to-date tutorials to creating Android apps with KMM. Main differences you’ll find are differing dependencies (i.e. Retrofit, Room, etc). In the iOS world it’s going to be more different from the basic iOS development, especially in the dependencies side (again, networking, persistence, etc). However, both of the above opinions are highly dependant on the architecture that you choose, as in how much of the logic you’ll want to share with KMM. The more you share (such as shared ViewModels), the more differences you’ll find from purely native development. I would say that it’s going to be somewhat difficult to start working with KMM unless you have a solid understanding of an architectural pattern that plays well with shared code. One such architectural guideline is Clean Architecture. An example of this is Use Cases: if you decide to go with platform-native ViewModels, you’ll still be able to share much of the business logic through Use Cases without polluting the layer with platform specifics.
On the point of up-to-date tutorials / guides / trainings: going with material that already uses Kotlin Flows will help you transition to KMM later on. LiveData is not so far from it and will get you in the correct mindset, but there’s still bit of a learning curve from LiveData -> Flows. Moreover, as @Lukasz Kalnik pointed out, I’d also recommend going with Jetpack Compose & SwiftUI. One reason for this, from KMM point of view, is that (IMO) most popular sample repos and projects use those frameworks. Having such references will help you along the way once you get to the KMM world.
l

Lukasz Kalnik

08/23/2022, 7:08 AM
Good point with the dependencies. There are some libraries which support KMM "out of the box" and if you want to make your life easier then it's preferable to go with them. Networking: Ktor Database: SQLDelight Dependency injection: Koin Longer list: https://github.com/terrakok/kmm-awesome#libraries
b

Ben Edwards

08/23/2022, 10:58 AM
@Lukasz Kalnik @Matti MK Thanks for the replies. So I guess what I am asking is are there any good tutorials for KMM? I am quite liking the masterclass I linked to and it seems like a good idea to t start to master (well kind of) basic android dev before going to KMM. I am a big fan of the idea of learning journeys. Tutorials that start at the beginning and guide you through learning with teaching and exercises. I'm hoping there is some good KMM teaching material that is designed for those who know base Kotlin android dev. Or maybe an article that discusses the pros/cons of different approaches to KMM?
l

Lukasz Kalnik

08/23/2022, 11:01 AM
Unfortunately I didn't find any tutorials yet. I assume that's because the whole KMM ecosystem is kind of "fluid", there is still a lot in development and it's hard to find one approach which could be described as a "best practice".
Also if you find a tutorial from say 1 year ago it will probably be already outdated by now. I think it's best to just pick a topic for an app and try to build it based on one of the different KMM sample projects. Then you will see what works for which use case.
m

Matti MK

08/23/2022, 11:03 AM
Not as far as I know, but I’ve never looked for one. KMM and everything around is changing very rapidly and I doubt such a tutorial/class would stay up-to-date for very long. There’s an official getting started guide, but that’s pretty much it AFAIK: https://kotlinlang.org/docs/multiplatform-mobile-getting-started.html However, there’s quite a lot of great sample projects that you can look into and find out the “best practices” for different topics. But as KMM is new, there’s no single best practice for architecture choices or dependencies.
l

Lukasz Kalnik

08/23/2022, 11:05 AM
If you're really into it, you can get in touch with folks at Touchlab: https://touchlab.co/. They do a lot of KMM development (including tooling) and consulting. They should also have/be able to recommend some good starting resources.
Kevin Galligan from Touchlab is worth following: https://twitter.com/kpgalligan
One of the interesting new articles: https://touchlab.co/droidcon-nyc-ios-app-with-compose/
3 Views