Live data from Hacker News

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

news.ycombinator.com

41–50 of 123 posts

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

#41
post #27

So I'm sure lots of people will think that this definitely doesn't qualify as "Best language to share code...", but Haskell has stuff for getting web, desktop, iOS, and Android out of one code base. It's called Obelisk ( https://github.com/obsidiansystems/obelisk ) and it's actually getting to be a pretty good development experience.

I love hacker news. This is the comment I came here for. Just use this : A language that is (at best) fringe on the platform you are using. Here's a toolset nobody has ever heard of. Now build your mission critical bit of infrastructure on this house of cards, wait for the toolset maintainers to be outpaced and under-resourced by underlying OS/platform changes and then have to rewrite the whole thing which if it does…

Classic HN - slave to the money god.

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

#42
post #40
post #27

Earlier quoted context omitted.

I love hacker news. This is the comment I came here for. Just use this : A language that is (at best) fringe on the platform you are using. Here's a toolset nobody has ever heard of. Now build your mission critical bit of infrastructure on this house of cards, wait for the toolset maintainers to be outpaced and under-resourced by underlying OS/platform changes and then have to rewrite the whole thing which if it does…

Well, developers are the kind of people that love to be contrarian, so it shouldn't be that surprising. Half the fun (in my mind) is doing something no one else is doing. Being novel. It's probably unwise in a business sense, but if everyone was being wise all the time, there wouldn't be much fun in software development.

You're not obligated to be a brutal capitalist as an engineer. It's okay to make decisions that are suboptimal (but still passable) for your employer but highly aligned with your own career interests.

If you always optimize for whichever company is employing you currently, you're doing yourself a disservice and essentially "leaving money on the table" :)

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

#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] and "Using native extensions for Adobe AIR" [3]

Note, the latest Adobe AIR SDK are now maintained by Harman [4]

[0] https://www.adobe.com/products/air.html

[1] https://help.adobe.com/en_US/air/build/index.html

[2] https://www.adobe.com/devnet/air/articles/extending-air.html

[3] https://help.adobe.com/en_US/air/build/WS597e5dadb9cc1e0253f...

[4] https://airsdk.harman.com/

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

#45
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.

You can't really share that between platforms.

Ah shame, I remember reading about targeting iOS at least with nim but didn't look to closely into it.

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

#46

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.

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

#47
post #10

Just use JavaScript. Javascriptcore is a lightweight way to execute JavaScript on iOS and you can use V8 context or duktape on Android. This way you can also update code in your app without an app store update.

Supporting a JS Engine is non-trivial. See React Native and Native Script. For example stacktraces etc.

With C++ in both Android Studio and X-Code you can put break points in the same IDE.

With JS you would use the browser to debug JS code, and Android Studio and X-Code to debug the native code. That split can be annoying.

I guess if the team that supports the JS engine is sufficiently large, i guess you can get more out shared JS code. The majority of the devs should be able to focus on JS development only. And a couple of specialists deal with "JS engine issues".

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

#48
post #29
post #15

C++. It is part of both SDKs, you have direct support for mixed mode debugging on the IDEs. No need of extra tooling. On Android JNI is always going to be a pain, but at least with C++ Studio gives you an hand on accessing JNI APIs.

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.

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

#49
post #28
post #15

C++. It is part of both SDKs, you have direct support for mixed mode debugging on the IDEs. No need of extra tooling. On Android JNI is always going to be a pain, but at least with C++ Studio gives you an hand on accessing JNI APIs.

I want to like this answer but not sure it's true. Do you mean bridging ObjectiveC++ and Swift? Apple is now deprecating ObjectiveC++ (after all the work we went to to make it work back in the NeXT days). I would like to integrate C++ code into a SwiftUI app but am not sure how to do it. Are there some iOS C++ APIs I'm overlooking?

So far I never saw anything in that regard.

In any case it isn't as if extern "C" isn't part of the language.

My answer regards using only SDK available languages, not that you write 100%bof the app in one of them

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

#50
post #28

Earlier quoted context omitted.

I want to like this answer but not sure it's true. Do you mean bridging ObjectiveC++ and Swift? Apple is now deprecating ObjectiveC++ (after all the work we went to to make it work back in the NeXT days). I would like to integrate C++ code into a SwiftUI app but am not sure how to do it. Are there some iOS C++ APIs I'm overlooking?

> Apple is now deprecating ObjectiveC++ How so? Objective-C++ drives a number of Apple projects, so I don't see how they're deprecating it.

Documentation seems to have vanished.
Post reply on HN