Live data from Hacker News

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

news.ycombinator.com

71–80 of 123 posts

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

#71
post #48

Earlier quoted context omitted.

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.

What vulnerabilities does C introduce that C++ doesn't?

For example it is easier to avoid buffer overflows with std::string than with C-style strings.

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

#72
post #60

Since no one else has said it, I'll be the voice of reason. Share your design specs only, and let each platform team write the implementation in the language that they think best. Yes, you'll have two teams spending time on doing the same thing. However, you'll get important benefits. Each team will be able to implement appropriately for their platform. While iPhones and Android phones are rather similar in terms of…

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 to save 200LOC here and there, just bite the bullet and write it twice.

Big thanks to whoever pointed out Kotlin Native: seems interesting enough to poke around with.

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

#73
post #70

Earlier quoted context omitted.

How do you propose that an security vulnerability in an iOS app that doesn’t result in a jailbreak will allow someone to copy the app from an iOS device on to another device? Also, are you claiming that using C == “not striving for quality” or that it is not “best practice” to use C? And on a side note, most corporations don’t care about “quality” or “best practice”, they care about shipping and selling software. Two…

Industry is young, but thankfully returning goods on app stores and suing companies for delivering bad software is starting to happen. I am claiming both when using a language whose security reports from Google, Apple, Microsoft, ARM, Linux kernel just increase in size every year with the amount of memory corruption and UB induced security exploits. Like those reports advise, usage of C should be constrained to envir…

Even the personal computer software business has been around almost 45 years if you count when Bill Gates was selling BASIC interpreters in the mid 70s.

What “safer” alternatives are better that give the performance needed, with tooling available and the cross platform requirements that the poster needs?

Also, you haven’t explained how a security vulnerability from a third party app can be “used for piracy”.

Where are all of the corporations that are being sued because of software quality and not using “best practices? I would say just the opposite, companies are being sued if anything for not meeting delivery dates.

The definition of enterprise software is basically poor quality software where the user is not the buyer and they have to work around bugs.

Consumer software is no better.

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

#74
Here's a Mozilla blog post about rewriting Firefox's Sync client code in Rust so the same code can be used on desktop, Android, and iOS. The FFI between the shared Rust code and C++, Java, and Swift app front ends is a little hairy but well encapsulated, generated code.

https://hacks.mozilla.org/2019/04/crossing-the-rust-ffi-fron...

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

#75
I'm surprised no one has pointed out the value of Ionic Framework (https://www.ionicframework.com). I'm a huge, huge proponent of this. TypeScript is a great language (in my opinion), UI code-sharing is inherent, and Capacitor (https://capacitor.ionicframework.com/) is great for all the native work you need to do. Worth noting you can do this in Angular, React, Vue, or pure JS.

This won't suit your needs for processing-heavy apps (though can WebWorkers help), but will work well for many apps (https://csform.com/top-10-apps-built-with-ionic-framework/ for a "top 10" list for examples).

I noticed after submitting that you mentioned machine-learning. Any reason you can't offload that to a web API and take the load off the client?

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

#76

Earlier quoted context omitted.

What vulnerabilities does C introduce that C++ doesn't?

For example it is easier to avoid buffer overflows with std::string than with C-style strings.

It’s also easier to avoid buffer overflows in C by using the “n” variants of C string library functions.

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

#78

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's the debugging experience like?

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

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

Can concur, we had huge success sharing our core business logic as a C++ library which was then used by UI on Android/iOS/Web and even desktop native apps.

Using Dropbox Djinni (https://github.com/dropbox/djinni) also helped with the horrible pain of JNI... although it's unmaintained these days. I guess people use SWiG now.

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

#80
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 pretty rudimentary for more complex logic - not having nice containers, things like std::thread or smart pointers can mean a lot of pain when trying to write code portable across platforms.

I don't think it's worth staying there - especially since C++ is a first party supported language on pretty much all platforms.

Post reply on HN