Live data from Hacker News

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

blogs.dropbox.com

11–20 of 335 posts

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

#11

It's funny that they have a hard time hiring experienced senior C++ devs even though the language has been around so long. Presumably it would have been easier to find someone really good at something newer like, say, Vue.

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

I tried using C++ and Objective C several years ago.

Compilation was incredibly slow. Maybe when C++ modules finally arrive things will improve.

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

#12
post #11

Earlier quoted context omitted.

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

I tried using C++ and Objective C several years ago. Compilation was incredibly slow. Maybe when C++ modules finally arrive things will improve.

I take it you haven't tried Swift ;)

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

#13
post #9

The overhead of C++ adoption actually prevented us from ever moving fully in this direction. Today, unlike in 2013 when they started, there are other options. For others considering code-sharing, another option not mentioned in their article is Rust for the core with Swift and Kotlin. Between bindgen, futures, serde_json and non-nullable pointers in Rust, those would satisfy their stated subcategories today. Companio…

How does Rust differ significantly from C++, other than the fact that neither platform's toolchain can compile it out of the box?

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

#14
I'm somewhat disappointed that this didn't work out, as I have usually promoted a C++ core along with a thin native wrapper as the solution for those looking to share code across platforms. At least they moved to native development, though, instead of some poor facsimile that was "easier"…

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

#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 something. Other than that, it's almost like the collective consciousnesses of Google and Apple conspire to make cost-effective code-sharing of typical CRUD apps almost impossible.

Here's a fine alternative to code-sharing: well first and foremost you need to have a good requirements spec. After that, implement it on one platform first in a platform agnostic way. So heavy use of delegates/interfaces/injections to handle platform-specific functionality, even for one-liners like getting current system time. So the code should be pure, boring, plain old Java, Kotlin, Swift, whatever. Minimal use of fancy language features that may not port cleanly. After one platform has the module in place and well-tested, do a copy/paste port to the other platform. You will find that the copy/paste port will actually uncover bugs, optimizations, edge cases, etc., that can then be ported back to the original platform. Things you would not have found if you were only writing the code once. It's like the most intense kind of PR code review you can get.

So I've found that copy/paste-port-based code sharing between platforms is not just a lesser evil, but actually a strategy that has its own unique benefits. If you get into a groove you can build up a set of regexes to give you a sloppy transpiler that does most of the tedious porting for you.

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

#16
post #9

The overhead of C++ adoption actually prevented us from ever moving fully in this direction. Today, unlike in 2013 when they started, there are other options. For others considering code-sharing, another option not mentioned in their article is Rust for the core with Swift and Kotlin. Between bindgen, futures, serde_json and non-nullable pointers in Rust, those would satisfy their stated subcategories today. Companio…

How does Rust differ significantly from C++, other than the fact that neither platform's toolchain can compile it out of the box?

Less foot guns. And it's not crazy in either env to have externally built libraries.

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

#17
There's quite a few places that are still dealing with 4 codebases with varying degrees of shared code. Desktop, mobile web, native Android, native iOS.

A shame, since many of them don't really need more than one responsive web codebase. Native apps do add value for many use cases, but not all.

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

#19
post #11

Earlier quoted context omitted.

I tried using C++ and Objective C several years ago. Compilation was incredibly slow. Maybe when C++ modules finally arrive things will improve.

I take it you haven't tried Swift ;)

Or (shudder) Scala. The only time I ever think “oh, this computer is a bit slow” of modern high end laptops is when it comes to Scala.

I like the language, but the compiler is painful.

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

#20

It's funny that they have a hard time hiring experienced senior C++ devs even though the language has been around so long. Presumably it would have been easier to find someone really good at something newer like, say, Vue.

"Hard time hiring" sometimes means that the candidates cost too much, which would make sense here since we're talking about senior C++ people.
Post reply on HN