News for hackers. Stuff that matters.
Re:Kotlin Multiplatform for Android and iOS Apps by lewisjoe on Monday September 25, 2023 @12:14PM (#37646267)
I'm puzzled why Kotlin isn't getting enough attention on HN, at least as much as Rust or Zig.

Kotlin is indeed popular in it's specific domain (Android & Java). But the company is keen to position it as "write once run anywhere" space with a strong focus on multiplatform development.

1. The build system provides platform specific bindings for free (huge plus compared to the hassle of writing the core in C/C++ and then hand-writing platform specific bindings)

2. Keen focus on enabling single codebase for multiple platforms.

3. The company went so far, as to build a multi-platform UI Framework (Compose Multiplatform) that directly renders to Skia and runs on all mobile/desktop platforms. And even on browsers (with wasm)

I find it odd, that such interesting a language / compiler finds little attention beyond its domain.

Is there any reasons for this that I'm missing?

Re:Kotlin Multiplatform for Android and iOS Apps by MarkMarine on Monday September 25, 2023 @12:31PM (#37646543)
I think modern Java has stolen a lot of Kotlin’s thunder. The differences between the languages shrink with each Java release, and server side Kotlin isn’t evangelized by its main cheerleader, google.

It’s a GC language, so rust/zig are not good comps. Go, Java, Scala, Server side JS/Node, or python. These are the comps.

Personally, I’ve written a number of non-trivial, server side applications in Kotlin. The extra cost of asking my colleagues to learn another language and some pain in the interop with Java has dampened adoption. It’s a shame, I find the coroutine library a joy to use, with none of the painful drawbacks of go, node, python, etc.

Re:Kotlin Multiplatform for Android and iOS Apps by colanderman on Monday September 25, 2023 @12:41PM (#37646700)
Don't forget C#/F#. Microsoft's been leaning hard into cross-platform with MAUI.
Re:Kotlin Multiplatform for Android and iOS Apps by callalex on Monday September 25, 2023 @03:04PM (#37648926)
Microsoft can only implement Embrace Extend Extinguish so many times before even the dumbest of developers starts to catch on and avoid being bitten.
Re:Kotlin Multiplatform for Android and iOS Apps by h4x0rr on Monday September 25, 2023 @04:08PM (#37649853)
Hot take: Microsoft can't do good UI frameworks and it shows. XAML makes some things really hard, resulting in loads of ValueConverters for example. Part of my bad experience might just be the learning curve but honestly I'm not surprised so much software is built using Electron.
Re:Kotlin Multiplatform for Android and iOS Apps by colanderman on Monday September 25, 2023 @04:23PM (#37650071)
I am actually using Avalonia+ReactiveUI for my current project (MAUI doesn't support Linux or F# last I checked), which I understand is similar to WPF... what a hot mess it is to wire up models to views in just the right way, especially in F#.
Re:Kotlin Multiplatform for Android and iOS Apps by Clamchop on Monday September 25, 2023 @04:56PM (#37650482)
These are all fair points for Java on the JVM or Android, but Kotlin Multiplatform does things that are well beyond the purview of the JCP.

It has downsides to be sure but it's not as simple as evaluating it as just another option for compiling to bytecode anymore.

Re:Kotlin Multiplatform for Android and iOS Apps by modernerd on Monday September 25, 2023 @12:32PM (#37646566)
There is a lot to love about Kotlin and I’m excited for its potential, but I’m waiting for some of the alpha and beta statuses to be lifted here before I commit more fully or recommend it for projects at work:

https://kotlinlang.org/docs/components-stability.html

(The new K2 compiler frontend is considered alpha but due to become stable with v2: https://blog.jetbrains.com/kotlin/2023/02/k2-kotlin-2-0/

Kotlin Native and Multiplatform are both listed as beta.)

Re:Kotlin Multiplatform for Android and iOS Apps by dickersnoodle on Monday September 25, 2023 @12:26PM (#37646454)
iOS dev here. What you're missing is that a ton of native-code developers (me included) aren't interested in adopting an abstraction layer that has to be tweaked to approximate the look and feel of the native OS UI layer when we could just built it natively to begin with and save all that effort. We've seen PhoneGap/Cordova, we've seen React Native and we'll keep seeing money thrown away on pretending that there aren't real platform differences when there are.
Re:Kotlin Multiplatform for Android and iOS Apps by frizlab on Monday September 25, 2023 @12:47PM (#37646816)
This. It’s exactly the same for me (also iOS dev, and I do Swift on the server too).
Re:Kotlin Multiplatform for Android and iOS Apps by mike_hearn on Monday September 25, 2023 @12:57PM (#37646993)
The idea is you can write SwiftUI on iOS, whilst connecting to business logic written in Kotlin.
Re:Kotlin Multiplatform for Android and iOS Apps by medo-bear on Monday September 25, 2023 @01:40PM (#37647696)
im not a phone app dev, but im curious, cant you already write backend code in another language and the ui in swift
Re:Kotlin Multiplatform for Android and iOS Apps by azarovalex on Monday September 25, 2023 @02:06PM (#37648083)
Business logic is not only about backend. Apps usually have a lot of client-side logic that can be written once in KMM and used on both platforms. See [1] for a high level architecture diagram.

I'm an iOS dev and I've been using KMM on a couple of projects for more than a year now. It's really a powerfull technology which allows teams to move faster, but there are downsides, for example lack of native Swift interop, though there are opensource tools trying to solve this [2].

[1]: https://github.com/Kotlin/kmm-production-sample/tree/master#... [2]: https://github.com/touchlab/SKIE

Re:Kotlin Multiplatform for Android and iOS Apps by dickersnoodle on Monday September 25, 2023 @03:39PM (#37649428)
Sort of but not really. SwiftUI is reactive, with view changes triggered by changes in Swift variables and those changes triggered using Combine. The later iterations of Swift include async/await to greatly simplify async code (normally but not always focused on network endpoints). You can write everything you need without having to drag Kotlin into the mix, and including Kotlin will require bridge code that seems (to me, at least) an unwanted obligation just to let some executive say "We saved some money by sharing code!".
Re:Kotlin Multiplatform for Android and iOS Apps by whoopsie on Monday September 25, 2023 @04:12PM (#37649918)
No no no. Just look at the janky stuff one needs to do to compile Kotlin for an iOS project. Plus, object lifetime semantics differ. Now you won’t be able to write Kotlin native code without thinking of iOS rules. So now you have the worst of unfamiliar worlds with a “most fast” product speed.
Re:Kotlin Multiplatform for Android and iOS Apps by Larrikin on Monday September 25, 2023 @01:02PM (#37647079)
As an Android developer that's been using Compose and multiplatform I believe the play is to get Android developers to be able to minimally adapt their apps to run on iOS. They don't pretend that you don't need to know anything about iOS but are trying to abstract as much (or as little) a way to compile to both.

The other multiplatform attempts failed because they were trying to use languages that neither side wanted or knew and pretended like you could drop in a dev from a completely different field and not need to know much about the platforms. If you did know the platform you were fighting against the framework in an unfamiliar language.

That said it is definitely not there yet, but I hope they get it to a reasonable place. I've enjoyed Android development and would love to be able to more simply port over a project without a complete rewrite.

Re:Kotlin Multiplatform for Android and iOS Apps by evereverever on Monday September 25, 2023 @07:03PM (#37651964)
Stack traces look like garbage though. I've developed a library for KMM. The iOS devs didn't want to touch it, so write once, make android devs keep it up. Also it was the network layer, so that's the easiest shit to write natively.
Re:Kotlin Multiplatform for Android and iOS Apps by sakex on Monday September 25, 2023 @12:56PM (#37646980)
I use Kotlin daily at my job (I have to) and I'm not impressed. It is a new language that ignores most of the innovations in Programming Language Theory from the last 20 years. It only improves on Java by making the syntax less verbose and adding coroutines but almost doesn't add any benefits in terms of semantics.
Re:Kotlin Multiplatform for Android and iOS Apps by wiseowise on Monday September 25, 2023 @01:34PM (#37647614)
> It is a new language that ignores most of the innovations in Programming Language Theory from the last 20 years.

Such as?

Re:Kotlin Multiplatform for Android and iOS Apps by osdev on Monday September 25, 2023 @01:13PM (#37647294)
Hi, I’m curious, can you elaborate on the language features that you think Kotlin ignores?
Re:Kotlin Multiplatform for Android and iOS Apps by brokenbyclouds on Monday September 25, 2023 @04:02PM (#37649770)
It's ok everyone, they must misspelled Go as Kotlin
Re:Kotlin Multiplatform for Android and iOS Apps by Clamchop on Monday September 25, 2023 @10:07PM (#37653426)
I'd really, genuinely be interested in reading more about this theory, and what your criticisms of kotlin are.

No, really, I'm interested!

Re:Kotlin Multiplatform for Android and iOS Apps by mu53 on Monday September 25, 2023 @02:36PM (#37648516)
Its trying to be everything, but its good at nothing. Even with spring boot, it has a painful edges.

Learning a language isn't a huge burden. Frameworks and libraries can alleviate huge burdens. Kotlin avoids the benefits of frameworks and libraries while giving meager benefits in term of language constructs.

Re:Kotlin Multiplatform for Android and iOS Apps by sierisimo on Wednesday September 27, 2023 @02:06AM (#37670780)
Can you elaborate on the painful edges and the benefits of frameworks avoided?

I wanna understand better as I do kotlin in daily basis, some with spring, some with ktor and some with android and I don't get your points.

Re:Kotlin Multiplatform for Android and iOS Apps by SpaghettiCthulu on Monday September 25, 2023 @05:28PM (#37650935)
`kotlinc-native` is one of the slowest compilers out there. Try compiling a "Hello, World!" program. It's slower than `rustc`. By a lot.