Live data from Hacker News

The not so hidden cost of sharing code between iOS and Android

blogs.dropbox.com

101–110 of 335 posts

Re: The not so hidden cost of sharing code between iOS and Android

#101
post #98
post #21

I just launched (like, an hour ago: https://news.ycombinator.com/item?id=20700196 ) a cross-platform app that is almost all shared code. In my case, the solution is a web app with very lightweight native wrappers, and I'm quite happy with it. Obviously that wouldn't be the perfect fit for all apps, but none of Dropbox's "(not so) hidden costs" are relevant in my case, and I suspect many apps would be a good fit for t…

Most cross-platform solutions are great in the beginning and then the problems start to come to surface as teams grow, requirements change, bugs are harder to track down, code needs to be updated, the next hot cross-platform framework comes along with new promises, etc.

You seem to be describing problems with all software that has to grow.

Re: The not so hidden cost of sharing code between iOS and Android

#102
post #75

Earlier quoted context omitted.

Yeah, I have 15 years of C++ experience, but not since 2012. So with C++11 and C++17 (and soon C++20) my skills have not aged well, even though I can still write C++03 just fine. It's no wonder 'senior' devs prefer to use plain C, where even C11 is not that different from C99.

> my skills have not aged well I don't think that's necessarily the case. C++'s famed backwards compatibility, source of so many issues, is also a fabulous strength. There's nothing stopping one from writing C++03, while gradually adapting C++11 and beyond as time/circumstances permit (which is what I'm doing at my job, maintaining a massive legacy codebase while stymied by slow uptake on newer compilers by my corpor…

The problem from Dropbox's perspective is that they're not merely hiring someone to create a solo greenfield C++ codebase, but to contribute quickly to a codebase written in whatever arbitrary subset of C++ they blessed.

Re: The not so hidden cost of sharing code between iOS and Android

#103

Recently worked at a company doing similar to this to support Windows and macOS. To add to the difficulty, they used Chromium as a UI front end much like Electron. All built in house though. They hired me as a JS/HTML/CSS dev, but same as the article states, the C++ work was the true bottleneck. They knew I had some C++ chops and set me to work doing C++ with a sprinkle of JS here and there. Due to incompatibilities…

> Due to incompatibilities in the compilers, there was a rats nest of dependencies, thousands of #ifdef’s to cover differing OS implementations, and we had to use some of the oldest versions of C++ to be compatible with both XCode and Visual Studio.

My current work has me on a single C++ code-base for Linux, Windows and MacOS (not electron though, just native). You can avoid a lot of headaches by avoiding the platform specific tools and instead cross compile using clang with a build system that works on all platforms (eg. ninja + meson).

Re: The not so hidden cost of sharing code between iOS and Android

#104
post #40

Earlier quoted context omitted.

Which framework are you using for this?

React Native

Done correctly != react native. I've had to shut down and migrate 3 RN projects because of how much of a mess it is. It's not even 1.0 and is a horrible choice for important apps.

Re: The not so hidden cost of sharing code between iOS and Android

#105
post #88
post #15

I have come to this same conclusion after many years. It's not cost-effective to have any bespoke business logic (models, controllers, etc.) shared between the two mobile platforms (don't get me started on sharing UI code). If you have some incredibly tricky low-level algorithm/library and/or need for speed, think database, crypto, intense graphics, etc., then fine, you may be able to swing a shared module in C++ or…

The article says it all - they chose the wrong language with no community support for the trail they were blazing and that technical debt destroyed their productivity. I achieved 90+% code share in Xamarin including UI across windows - ios - andriod. 100% buisness logic shared. You can write cross-platform UIs, and swap out to native code on a widget by widget basis. Threading is seemless. Sure it has its own set of…

Xamarin is indeed the closest there is to the holy grail of cross-mobile development. I too had some success with it for a small project at first, but just like the theme of the blog post, the challenge is in the long-term maintenance being cost-effective, not just the initial development. Especially in the face of these adversarial platforms constantly changing things underfoot. For example in Android recently I've been forced to switch to the AndroidX library, and iOS has Dark Mode coming out. Will Xamarin support both of those platform changes cleanly? Maybe, but it's a risk.

I'd be happy to hear if the project you worked on has been cost-effective to maintain in the long term. Then at least someone has seen the mountain top!

Re: The not so hidden cost of sharing code between iOS and Android

#106
I've been using C++ to share code between iOS and Android for years and have come to the same conclusion. I developed the C++ code on desktop operating systems which was easier to debug, but once you move it to mobile then the debugging gets a lot harder (on Android at least).

The overhead of the JNI interface is quite a lot of work too. Luckily I had a UML model that I generated the interfaces out of, so adding JNI was just a matter of templating this out of the UML, but it was still quite a bit of work.

On iOS the situation has gotten worse in that the interface between Swift and C++ has to go through C, so if you are using C++ you need a special interface layer, which is almost like the JNI situation on Android.

So you have the trade-off of on one hand having two code bases (Swift, Kotlin) and the associated headache of keeping them in sync, versus the extra work of maintaining the C++ interface layers and testing and debugging on each platform. In the end I now believe that it is better to work with the platform native development tools rather than trying to share C++.

As far as finding developers goes, because of the rarity of using C++ on mobile there will not be a lot of developers with this experience. I work remotely and have found that any remote C++ work is very rare, Swift and Kotlin are a lot easier to find work with (it's still more difficult that you would think to get remote work of any type).

Re: The not so hidden cost of sharing code between iOS and Android

#107
I wish all the articles and blog post are like that. The first sentence sort of gives away what you need to know.

Until very recently, Dropbox had a technical strategy on mobile of sharing code between iOS and Android via C++. The idea behind this strategy was simple—write the code once in C++ instead of twice in Java and Objective C.

A lot of people will stop reading after this, for those interested they could continue with the details.

Re: The not so hidden cost of sharing code between iOS and Android

#108

Earlier quoted context omitted.

I wonder if that is a symptom of C++ having many recent revisions, thereby influencing, misleadingly, the definition of "experienced".

Yeah, I have 15 years of C++ experience, but not since 2012. So with C++11 and C++17 (and soon C++20) my skills have not aged well, even though I can still write C++03 just fine. It's no wonder 'senior' devs prefer to use plain C, where even C11 is not that different from C99.

C is just easier to keep most of the rules in your head for. I prefer C any day, especially in an embedded system.

Re: The not so hidden cost of sharing code between iOS and Android

#109
Due to C++ inherently close connection with the OS I see this as an absolute happening. But they should've go with Objective-C and Java and stay with them, as they were the matured technologies back in 2013 for their target OSes. Instead they chose another young ones. Oh well, not going to cry due to Dropbox making Kotlin and Swift better due to still lack of libraries there for their purposes. The more the merrier, that's my motto. My absolute fear is the manager's dream to only UML be as programming language and they drag'n'drop with no coding behind (the wet dream back in 2005 my manager at Siemens had, and he told me the world is going that way. Ya sure buddy, not if we let it happen and so far instead of unification we have even more diversification)

Re: The not so hidden cost of sharing code between iOS and Android

#110
The common thread that I personally see between dropbox and airbnb, though completely different language sets, is adopting a shared codebase in a "brown field" manner.

Airbnb admits if they were able to greenfield React Native then there's a world where it would have worked.

Separately, the complexity of Airbnb and Dropbox as apps is very high compared to what I believe are the ideal use cases - simple interface apps that are thin wrappers on top of APIs.

Post reply on HN