Live data from Hacker News

Kotlin Multiplatform for Android and iOS

kotlindevelopment.com

11–20 of 38 posts

Re: Kotlin Multiplatform for Android and iOS

#11

Looks great! My biggest concern and one of the reasons I'm not using Swift or C++ for a cross platform library is that most of the dependencies you (at least I need) need don't support those languages (Auth0, Firebase, Crashlytics etc...). So you end up writing more complex code to make that also work. If Kotlin native can bring those types of libraries to be supported it will be huge IMO.

> Swift

How you think is possible to use swift on android? The only almost decent way is https://www.elementscompiler.com/elements/default.aspx and is not enough:

https://www.reddit.com/r/swift/comments/8zb9y1/state_of_swif...

Re: Kotlin Multiplatform for Android and iOS

#12
post #8

In essence, JetBrains has caught up to where Xamarin was prior to the announcement of Xamarin.Forms: the ability from one solution to have separate iOS and Android UI applications with a business logic library shared between the two, all written in C# or F# (the two languages supported by the Mono compiler). The main difference is that one of the vendors actually supports the language in question (Kotlin) as a first-…

> The main difference is that one of the vendors actually supports the language in question (Kotlin) as a first-class citizen. How is this different for Xamarin? C# has first class support on Windows.

The context of the article is about iOS & Android apps, so 1st class support on Windows is nice, but not germane.

Re: Kotlin Multiplatform for Android and iOS

#13
Seems like a gimmick to me.

In a nutshell this has the same limitation has Xamarin.

The Business Logic is shared , but the UI Logic and the Technical Logic aren't shared or not completely.

The Xamarin community has been struggling with this issue for half a decade and they ended up re-writting their own rendering engine[0] (similar to Flutter) in C# on top of Xamarin to obtain truly MVVM Cross-Platform Framework.

My point here is very simple , getting Kotlin to run on iOS is great, but it's somewhat a waste of time because of how much time and effort it would talk to create a Runtime or Rendering Engine to normalize UI/UX on differents platforms.

[0]https://github.com/AvaloniaUI/Avalonia

Re: Kotlin Multiplatform for Android and iOS

#14
post #8

In essence, JetBrains has caught up to where Xamarin was prior to the announcement of Xamarin.Forms: the ability from one solution to have separate iOS and Android UI applications with a business logic library shared between the two, all written in C# or F# (the two languages supported by the Mono compiler). The main difference is that one of the vendors actually supports the language in question (Kotlin) as a first-…

> The main difference is that one of the vendors actually supports the language in question (Kotlin) as a first-class citizen. How is this different for Xamarin? C# has first class support on Windows.

Xamarin's "first class" support for Windows is Windows Store only though?

Re: Kotlin Multiplatform for Android and iOS

#15
The thing that I still don't know about are how would things like data persistence be handled in a cross platform manner?

I recently built a kotlin Android app for work, and our architecture is tightly coupled to Android's Room database and LiveData objects. Obviously if we build it to be cross platform we wouldn't be able to use a Room database or LiveData objects on an iOS device. Would we have to roll our own persistence layer in a cross platform application? Or would we share business logic but still write a persistence layer using platform specific code?

It's not just persistence too. Any lower level API provided by the platform would still need to be written twice, right? Accessing the camera, the devices GPS location, or anything hardware related still needs an implementation for both platforms. Or would we eventually see libraries that would abstract this layer out, similar to react native?

Edit: Another thought...I haven't done much iOS development but the whole async nature of Android apps with the UI thread and background threads also seems like it would be a nightmare to deal with in a cross platform way. Does iOS involve a lot of async threads?

Re: Kotlin Multiplatform for Android and iOS

#16
post #10

Earlier quoted context omitted.

> The main difference is that one of the vendors actually supports the language in question (Kotlin) as a first-class citizen. How is this different for Xamarin? C# has first class support on Windows.

Windows isn't a mobile platform. They tried 2.5 times and have given up. In mobile it's iOS and Android, and neither Apple nor Google recognize C# as a first-class language. If you can write a compiler that emits code that LLVM can compile to ARM binary with Xcode or package your MSIL with a micro .NET VM on Android, then more power to you but Apple and Google aren't going to help you if you get stuck.

Windows tablets, laptops and 2-1 devices are quite mobile to me.

Re: Kotlin Multiplatform for Android and iOS

#17

Looks great! My biggest concern and one of the reasons I'm not using Swift or C++ for a cross platform library is that most of the dependencies you (at least I need) need don't support those languages (Auth0, Firebase, Crashlytics etc...). So you end up writing more complex code to make that also work. If Kotlin native can bring those types of libraries to be supported it will be huge IMO.

It is not only a matter of language.

The developer experience with the NDK is quite bad, as if Google makes it on purpose for only the persistent developers to actually succeed at it.

Re: Kotlin Multiplatform for Android and iOS

#18
post #15

The thing that I still don't know about are how would things like data persistence be handled in a cross platform manner? I recently built a kotlin Android app for work, and our architecture is tightly coupled to Android's Room database and LiveData objects. Obviously if we build it to be cross platform we wouldn't be able to use a Room database or LiveData objects on an iOS device. Would we have to roll our own pers…

I'd suggest to use SQLite as a persistent storage. It's very fast, convenient and cross-platform.

Re: Kotlin Multiplatform for Android and iOS

#19
post #15

The thing that I still don't know about are how would things like data persistence be handled in a cross platform manner? I recently built a kotlin Android app for work, and our architecture is tightly coupled to Android's Room database and LiveData objects. Obviously if we build it to be cross platform we wouldn't be able to use a Room database or LiveData objects on an iOS device. Would we have to roll our own pers…

I think the way is to write libraries for these use-cases. There is already a persistence lib for Kotlin Native called KNArch.db https://github.com/touchlab/knarch.db and it supports Android too.

We are already using libraries to make easier to use background threads (RxJava, RxSwift) so I don't think it's that hard to implement a cross platform lib for that purpose. JetBrains is already trying to tackle the task with Coroutines for Kotlin Native: https://github.com/Kotlin/kotlinx.coroutines/tree/master/nat...

Re: Kotlin Multiplatform for Android and iOS

#20
post #16
post #10

Earlier quoted context omitted.

Windows isn't a mobile platform. They tried 2.5 times and have given up. In mobile it's iOS and Android, and neither Apple nor Google recognize C# as a first-class language. If you can write a compiler that emits code that LLVM can compile to ARM binary with Xcode or package your MSIL with a micro .NET VM on Android, then more power to you but Apple and Google aren't going to help you if you get stuck.

Windows tablets, laptops and 2-1 devices are quite mobile to me.

And an AS/400 was perfectly "mobile" to Arnold S. back in his prime. :-)
Post reply on HN