<story><title>The not so hidden cost of sharing code between iOS and Android</title><url>https://blogs.dropbox.com/tech/2019/08/the-not-so-hidden-cost-of-sharing-code-between-ios-and-android/</url></story><parent_chain><item><author>mmastrac</author><text>We&amp;#x27;ve had a mostly different (positive) experience doing a similar thing at FullStory for mobile instrumentation, though I think I know where some of the key differences are.&lt;p&gt;Our core &amp;quot;business logic&amp;quot; lives in Rust. This is a shared bit of code between Android &amp;amp; iOS that mainly deals with orchestration, serialization, and server communication. We managed to extract ~1&amp;#x2F;2 of each platform&amp;#x27;s native code into this shared orchestration. What&amp;#x27;s left on each platform is more like a platform driver.&lt;p&gt;I fully admit that things are different for us because we&amp;#x27;re not dealing with a bunch of UI that we manage (instead we&amp;#x27;re dealing with UI that our customers have written in Java&amp;#x2F;Swift&amp;#x2F;Objective-C&amp;#x2F;etc), but I think that there&amp;#x27;s a few places where we&amp;#x27;ve made this work in a better way:&lt;p&gt;- We&amp;#x27;ve chosen flatbuffers to serialize most (not all) of the data between the platform drivers and the shared library.&lt;p&gt;- We&amp;#x27;re using a language that&amp;#x27;s a little more hip. It&amp;#x27;s still not very easy to hire Rust developers, but developers interested in Rust are _very_ interested.&lt;p&gt;- We built tooling early on to make this pretty seamless. Our Rust code builds in XCode and gradle, so there&amp;#x27;s no real friction to a developer getting up and running.&lt;p&gt;Our team is about a year in on this transition to Rust and so far it&amp;#x27;s helped us move far quicker, especially given the size of our team.</text></item></parent_chain><comment><author>charlesdm</author><text>As someone with plenty of C++ knowledge on mobile, I would expect there to be more C++ devs available with good mobile skills than there are rust devs?&lt;p&gt;Maybe my own viewpoint is twisting the amount of devs I think are available, but I don&amp;#x27;t think the choice dropbox originally made was crazy. C++ is a great way to share complex code over multiple platforms (i.e. desktop + mobile) if you&amp;#x27;re running a relatively small engineering team with limited resources.&lt;p&gt;Now, if you have semi unlimited resources, it makes sense to rebuild things natively for each platform in many cases. But Dropbox might not have been around, had they not maken the choice to share part of their codebase cross platforms.</text></comment>
<story><title>The not so hidden cost of sharing code between iOS and Android</title><url>https://blogs.dropbox.com/tech/2019/08/the-not-so-hidden-cost-of-sharing-code-between-ios-and-android/</url></story><parent_chain><item><author>mmastrac</author><text>We&amp;#x27;ve had a mostly different (positive) experience doing a similar thing at FullStory for mobile instrumentation, though I think I know where some of the key differences are.&lt;p&gt;Our core &amp;quot;business logic&amp;quot; lives in Rust. This is a shared bit of code between Android &amp;amp; iOS that mainly deals with orchestration, serialization, and server communication. We managed to extract ~1&amp;#x2F;2 of each platform&amp;#x27;s native code into this shared orchestration. What&amp;#x27;s left on each platform is more like a platform driver.&lt;p&gt;I fully admit that things are different for us because we&amp;#x27;re not dealing with a bunch of UI that we manage (instead we&amp;#x27;re dealing with UI that our customers have written in Java&amp;#x2F;Swift&amp;#x2F;Objective-C&amp;#x2F;etc), but I think that there&amp;#x27;s a few places where we&amp;#x27;ve made this work in a better way:&lt;p&gt;- We&amp;#x27;ve chosen flatbuffers to serialize most (not all) of the data between the platform drivers and the shared library.&lt;p&gt;- We&amp;#x27;re using a language that&amp;#x27;s a little more hip. It&amp;#x27;s still not very easy to hire Rust developers, but developers interested in Rust are _very_ interested.&lt;p&gt;- We built tooling early on to make this pretty seamless. Our Rust code builds in XCode and gradle, so there&amp;#x27;s no real friction to a developer getting up and running.&lt;p&gt;Our team is about a year in on this transition to Rust and so far it&amp;#x27;s helped us move far quicker, especially given the size of our team.</text></item></parent_chain><comment><author>manmal</author><text>Kotlin Native comes to mind - it generates binaries that can easily integrated with gradle and cocoapods, complete with headers&amp;#x2F;interfaces.&lt;p&gt;Do you also keep ViewModels or things like an AuthManager (incl Keychain) or view coordinators in Rust?</text></comment>