Live data from Hacker News

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

news.ycombinator.com

21–30 of 123 posts

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

#21

Earlier quoted context omitted.

which is not allowed on iOS ... Edit: Sorry for being unclear, was only referring to the updating JS on the fly and circumventing App Store part. Obviously (facepalm) ... ️

Which part isn't allowed? A project I worked on did this a few years ago.

I think there is some confusion around this. You can use Javascript with iOS if you use Webkit + JavaScript Core, and ship all your features in the binary that your app uses.

2.5.2 "Apps should be self-contained in their bundles, and may not read or write data outside the designated container area, nor may they download, install, or execute code which introduces or changes features or functionality of the app, including other apps."

and

4.7 " your app must use WebKit and JavaScript Core to run third-party software and should not attempt to extend or expose native platform APIs to third-party software"

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

#23
post #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

Gomobile bridges Java and ObjectiveC/Swift to Go, and probably entails the same overhead the author is trying to avoid.

Shameless plug: If you like Go and immediate mode UIs in particular, Gio[0] runs the same Go code across desktop and mobile alike. No bridging or native code required.

If you like a more mature framework and don't mind Dart, I think Flutter is an attractive toolkit. I started Gio wanting to write a Flutter clone in Go before going for the immediate mode design.

[0] https://gioui.org

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

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

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

#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 doesn't kill your startup, will certainly massively impact its resources.

Go! (THIS IS A JOKE)

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

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

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

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