Tony Kazanjian

    Tony Kazanjian

    7 months ago
    Hey KMP people! Just have a question I'd like to ask the community about what it was like getting started writing Kotlin Multiplatform apps from a primarily Kotlin and/or Android background. What were the gotchas, pain points, or assumptions you had to overcome when you first got started?
    Landry Norris

    Landry Norris

    7 months ago
    The hardest one for me was freezing on iOS builds. I would build, debug, and test on Android until I was happy with the app, then open an iOS simulator and… InvalidMutabilityException. The new memory model seems to work great so far, so hopefully this won’t be a problem in the future.
    Russell Stewart

    Russell Stewart

    7 months ago
    +1 on that. Learning to think in Immutable took a little doing, but once I got the hang of it it wasn't that hard. In some ways, I would even say it enforces good practices. The other big cognitive shift for me was learning to separate Kotlin from Kotlin JVM. When you're writing Kotlin code on Android you're writing against the JVM, which means you have access to all of the standard JVM libraries - from simple things like String formatting to more sophisticated tools like Retrofit. When you're in Kotlin Native (i.e., writing for the common module in KMM), all of that is gone, and K/N doesn't have anywhere near as many or as mature support libraries as Java does, because it's so much newer. The language may be familiar, but the environment is very different. Many of the things you have learned to take for granted as an Android developer are no longer there, and you have to either find replacements for them (which means hunting down and evaluating different libraries and learning new APIs), or use
    expect/actual
    to implement them on each specific platform.
    Grégory Lureau

    Grégory Lureau

    7 months ago
    +1 o Kotlin vs Kotlin JVM. Also I use JS/Typescript export, and having a nice API from Kotlin to Natives and typescript was a big pain point, mainly because you have to level down (like avoid using Long for example) or find tricks (like generating facade dedicated to a specific platform). Also concepts like "File" or multithreading is quite different on a web browser, (same for Channel/Flow not exportable in JS), and it's not always obvious how you want to deal with those concepts in a "generic"/"multiplatform" way. Tech is still young, so there is not a lot of example or a consensus on how to do everything (compared to Android).
    Russell Stewart

    Russell Stewart

    7 months ago
    Yeah, I haven't even touched Kotlin JS yet. I'm sure that's a whole other can of worms.
    Landry Norris

    Landry Norris

    7 months ago
    I think commonMain used to require you to write compatible with all targets, even those you weren't using. I always had to make basically a 'anything but JS' source set.
    Michael Paus

    Michael Paus

    7 months ago
    Russell Stewart

    Russell Stewart

    7 months ago
    Yeah, I saw that the other day. Definitely good to know.
    Tony Kazanjian

    Tony Kazanjian

    7 months ago
    Thank you for the responses everyone! I can definitely relate to the mindset shift coming in as an Android developer and realizing Kotlin/JVM != Kotlin