Live data from Hacker News

Ask HN: Best language to share code between an Android and iOS app?

news.ycombinator.com

1–10 of 123 posts

Ask HN: Best language to share code between an Android and iOS app?

#1
Hello app developers of HN!

My team owns an Android (Kotlin) and iOS (Swift) app. The app is responsible for processing data, submitting to ML models, and then displaying results in a UI. We chose to do a lot of that processing in a shared Rust component. What we have found is a high overhead of bridging Kotlin/Swift to Rust. Some core logic has also seeped into our bridging code resulting in some duplication (exactly what we were trying to avoid).

With that, those of you who have found yourselves in similar situations, which language would you choose to be shared between your Android and iOS app (if any)?

Re: Ask HN: Best language to share code between an Android and iOS app?

#2
I use c++ rather than rust because as much as I would love to use the best language its just not so well supported on mobile compared to c/c++. I'm not sure how well flutter ffi does using rust compared to more mainstream approaches its possible that flutter ffi is more friendly to rust than jni/kotlin.

Re: Ask HN: Best language to share code between an Android and iOS app?

#4
One way would be to host a script engine and run the script language, e.g. JavaScript. Another would be to create your own grammar and simultaneously translate to Kotlin and Swift. You could even use a strict subset of either Kotlin or Swift then you'd only have to deal with one translator.

Re: Ask HN: Best language to share code between an Android and iOS app?

#5
In Go, there is an official, experimental project called gomobile [0] that allows one to generate a Java or Objective C binding to be used in mobile projects based on Go source code.

It comes with some restrictions and is still deemed experimental. But it could be a viable choice in the days to come.

[0] https://github.com/golang/mobile

Post reply on HN