Live data from Hacker News

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

news.ycombinator.com

91–100 of 123 posts

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

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

yep really

I know it, few other dev know it too, and the rest well...

they will keep spewing stupid stuff about how flash is dead and ignore that wonderful tech

their loss

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

#93

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

What tipped the scales over to Kotlin Native for your team over Rust?

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

#94
You should share design specs between client teams and allow each of them to implement them within the parameters of what's expected on each platform. Don't force them to have the exact same UI at the cost of platform-specific idioms. It hurts customers on both platforms to take that approach.

Your business logic should be, to the maximum extent, implemented once on the server. Your client implementations should simply display what the server has computed, once. Caching it is fine, rendering it locally is fine for the most part, and you get a clean, well-fitted, elegant UI for it.

Any limited amounts of business logic that must be correct and truthful should be implemented as a Rust (or if you insist, a limited, well-defined subset of C++) library with C linkages and idiomatic wrappers for iOS and Android. If this can be shared with the server and/or web front-end (via emscripten for instance), it should be. It's usually painful to do this, but there's usually only a small part of your codebase that should fall under this section.

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

#96

Xamarin (C#) and Cordova (JavaScript) are the usual suspects for such multiplatform endeavours. You should not use three languages in production if one is enough.

There's very limited appetite for introducing JavaScript on any client platforms. Your iOS app has to introduce a garbage collector, bridging, and yet another language that nobody on your team knows. Android has to spin up a second garbage collector.

C# has all the same problems for core logic, and is all fine and good but you can't really get a native enough interface out of it.

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

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

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

Toolchain integration matters. Just use c++.

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

#99
post #88

Earlier quoted context omitted.

Why subject yourself to that risk when you can just use C++ and make everyone's lives easier? Is there a benefit to using C?

What “risk” is there in an overflow from using strncmp, strncpy, etc? C++ still isn’t as easy to interop with other languages as C and the low level APIs built into operating systems are not going to use C++/STL and you still end up converting to standard C strings and arrays.

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.

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

#100

Earlier quoted context omitted.

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?

This is the official docs

https://kotlinlang.org/docs/reference/multiplatform.html

I've also done multi platform recently.

I've taken a contract first approach. Swagger / openapi for rest clients. Outside of that I use vertx which has bindings for almost every platform. With those two I can account for interoperability across all platforms.

Big hitches

* No ts.d defintions at this time. But: https://github.com/vojtechhabarta/typescript-generator

* Dukat for automatic typescript definition importing (beta) https://github.com/Kotlin/dukat

* I've not done LLVM iOS. But I've read of some generic issues.

They are improving dependency management to handle multi platform. I can't find a link but it was on their blog

Post reply on HN