Live data from Hacker News

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

news.ycombinator.com

31–40 of 123 posts

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

#31
We use JavaScript for sharing code between devices(iOS & Android), browser as well as the server. Surprisingly, we haven't faced any of the problems, that Dropbox claims to have faced (https://blogs.dropbox.com/tech/2019/08/the-not-so-hidden-cos...).

Pros:

1. Sharing native APIs with JS runtime and vice versa, was well supported & trivial to implement.

2. Easy to find skill-set.

3. We can run the same code in browsers as well.

Cons:

1. The app will be slightly heavier in Android (as V8 has to be bundled with the app. iOS allows using native JsCore runtime.)

2. The shared code runs slower (Obvious, because dynamic language).

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

#32
I'm not completely sure about your requirement, but as a game developer who uses Unity everyday, I would recommend it. Core graphics and UI components are available out of the box, and sometimes even when we need an app(nothing like a game) that need to access native APIs of the platform, we use Unity. It used C# as the default language, and platform-specific core logic can be separated within the code, using #directives so it's pretty straightforward.[edit: typo]

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

#33

We use JavaScript for sharing code between devices(iOS & Android), browser as well as the server. Surprisingly, we haven't faced any of the problems, that Dropbox claims to have faced ( https://blogs.dropbox.com/tech/2019/08/the-not-so-hidden-cos... ). Pros: 1. Sharing native APIs with JS runtime and vice versa, was well supported & trivial to implement. 2. Easy to find skill-set. 3. We can run the same code in brows…

> as V8 has to be bundled with the app.

Cant you make use of Webview somehow? It has the benefit of being updated from the market if a security issue is found.

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

#34
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?

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

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

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

I'd push for Rust/C++ with C linkage.

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

#37
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

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

#38
post #14

C++ is first-class in Android via NDK. You can write directly to your app's memory from a C++ library without having go through FFI. I'm pretty sure it's the same for iOS but through a C ABI.

I wouldn't call C++ through the NDK "first class", especially compared to Objective-C++ on iOS.

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

#39
Something just crossed my mind while reading the question, that Swift could be a good candidate. Turns out there are compatibility layers that are based on Swift:

https://www.scade.io

https://academy.realm.io/posts/swift-on-android/

https://blog.readdle.com/why-we-use-swift-for-android-db449f...

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

#40
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…

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.
Post reply on HN