Live data from Hacker News

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

news.ycombinator.com

51–60 of 123 posts

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

#51
post #44

ActionScript 3.0 with the Adobe AIR runtime you will be able to publish to iOS, Android, Windows and macOS, see "Adobe AIR" [0] ActionScript is something similar to TypeScript you will have access to the whole Flash stack and more, see "Building Adobe AIR Applications" [1] with ActionScript Native Extension (ANE) you will be able to add your native code with an easy to use AS3 interface, see "Extending Adobe AIR" [2]…

Actionscript? Really?

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

#53

I have great success using Kotlin Multiplatform to share code between iOS and Android. Have a look at my Android Jetpack Compose and iOS SwiftUI project sharing the common logic for a game https://github.com/SimonSchubert/Braincup

It's worth to mention that it also supports native Linux, Windows and macOS buildings. Plus web via JavaScript and server via jvm.

This is really cool. Care to share some resources from which others can learn to get started?

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

#54
post #48
post #29

Earlier quoted context omitted.

I would say use C. Interfacing C with Java is simple JNI. Interfacing C with Swift is very simple, too.

C is also very simple to add security exploits to your app. I would never advise C unless the platform is lacking of a C++ compiler. Just use extern "C" at the boundaries.

A super thin layer made of C between say Objective-C or Swift and C++ is quite convenient though and doesn't add much of an security risk. See it as the lowest common denominator.

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

#55
post #7

I'm not an expert but you could consider sharing Swift (or Kotlin) code between platforms. Nim ( https://nim-lang.org ) could also be explored.

Came here to mention nim that I've followed with great interest. As it compiles to C you can probably use it just about everywhere.

As far as android support this guy is working on adding support to android via Dalvik assembly. The usual approach to get nim to work with android would be JNI but that might cause problems for example with x86 android machines if I am not mistaken. https://github.com/akavel/dali

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

#57
post #48
post #29

Earlier quoted context omitted.

I would say use C. Interfacing C with Java is simple JNI. Interfacing C with Swift is very simple, too.

C is also very simple to add security exploits to your app. I would never advise C unless the platform is lacking of a C++ compiler. Just use extern "C" at the boundaries.

What’s the threat of a security vulnerability in a 3rd party mobile app that tightly sandboxes your app - especially for a none financial app? I would think that if even a vulnerable app could affect other running processes or the OS itself, you’ve found a vulnerability in the underlying OS.

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

#58

We're using kotlin native, after considering rust for a bit. It's been working great, we've had it in production for about six months. Main advantages are * kotlin is a nice language with good type support * has good swift bindings out of the box * also compiles to js and cpp so we can use it in our Web product as well

How much work do you have getting it into js?

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

#60
Since no one else has said it, I'll be the voice of reason.

Share your design specs only, and let each platform team write the implementation in the language that they think best.

Yes, you'll have two teams spending time on doing the same thing. However, you'll get important benefits.

Each team will be able to implement appropriately for their platform. While iPhones and Android phones are rather similar in terms of capability, the interaction models have a lot of differences, and forcing a common component often results in non-native feeling apps. Users will be at best confused, and at worst insulted by this.

Additionally, when you have two teams working on similar problems, they can help each other. Training on this interaction with things known to be pretty much the same helps people realize they can do it with things that aren't obvious. Meeting on a regular basis to discuss things that worked/didn't on the various platforms will help them all.

Post reply on HN