Live data from Hacker News

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

news.ycombinator.com

111–120 of 123 posts

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

#111
post #72

Earlier quoted context omitted.

This is a UI-centric take. There are lots of internals that could/should be shared between apps. Recently relevant examples: a customized WebRTC stack, a websocket client with extra authentication and delivery rules. FWIW, my take on this has been to embrace Conway's law: if you have enough shared work to form a team around it, then break off a c++/whatever library and a team to maintain it. But if the hope is just t…

This is exactly what Dropbox has just abandoned. https://blogs.dropbox.com/tech/2019/08/the-not-so-hidden-cos...

In this case they lost there C++ team, so following Conways law they went back to separate code based.

Also the open source C++ ecosystem has advanced quite a bit since when they did there project. You would be able to spend much more time on the problem domain, and zero time on writing a JSON library for example.

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

#112
I have 22 years of shipping products on time with Delphi. The latest versions do a wonderful job compiling to android, iOS, macapp or Windows.

Delphi is not cheap, but in my case the time to market, and tight release dates make it worth.

www.embarcadero.com/products

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

#114
post #113
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.

Nim generates C, C++, Objective-C and js - so yes, you can target Android and iOS

Right, thought so. Thanks.

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

#115
FullStory is using Rust for our shared code, however the other sides are different: Java & Objective-C. It seems to be working pretty well for us so far.

Our requirements are probably a bit different than yours, though, because we're shipping a tool for app developers rather than the app itself. In particular, Objective-C was chosen over Swift because we didn't want to risk potential conflicts if our customers were using a different version of Swift and/or have to bundle a Swift runtime for older iOS versions.

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

#116
Kotlin can generate both JVM bytecode and iOS binaries. I've successfully shared code between iOS and Android projects using Kotlin before. The overhead is quite low, and, all in all, I was quite satisfied with the results.

However, a lot of the tooling around this is experimental, so you might want to tread carefully here.

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

#118
I do a lot of consulting for clients who use Embarcadero's Delphi to create native iOS and Android apps from a single source base. Delphi is a commercial product, that comes with its price tag and there is, of course, a learning curve, but once you know the processes you can create great multi-platform mobile apps, with way less effort than having one team on Xcode and the other on Android Studio.

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

#119
RAD Studio let's you build cross platform apps targeting Android, iOS, macOS, Windows, Linux, and HTML5 with a single codebase and single UI. Choose either Object Pascal or C++.

I prefer the Object Pascal side but the C++ side is also powerful because it solves some of the problems that the Dropbox team talked about in their "The (not so) hidden cost of sharing code between iOS and Android" article.

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

#120

Earlier quoted context omitted.

strncpy notoriously doesn't necessarily 0-terminate. (It also always pads the full length with zeroes if necessary, so it's almost never what you actually want to do.) The C standard library is full of these footguns. I won't say C++ doesn't have its bad parts, and I certainly wouldn't say that it's impossible to avoid the bad parts of C (some would), but you probably aren't going to manage.

If all of your string manipulation is working with the knowledge of the maximum size, how is that any different than the standard Pascal or BSTR string handling where the size of the string can be found in the first two bytes of the string? The typical error case with C is something like char *a = “abcd”; //5 bytes char *b = “efgh”; char c[8]; strcpy(c,a); strcat(c,b); //buffer overflow by 1 byte. If you used the “n”…

That might work - if you always use that pattern, and never, never deviate from it, including in all library functions that you ever call with your strings. That seems very brittle and error prone, though.

And why, when you have C++ strings that just handle all of that for you?

Post reply on HN