Skip to content

Instantly share code, notes, and snippets.

@jtlapp
Last active August 16, 2019 16:59
Show Gist options
  • Save jtlapp/b34f73a62ca240dc1234fd190f1371b8 to your computer and use it in GitHub Desktop.
Save jtlapp/b34f73a62ca240dc1234fd190f1371b8 to your computer and use it in GitHub Desktop.
Looking for one mobile platform API in multiple languages

Is there a single mobile OS/UI abstraction implemented for both Swift and Java that makes cross platform development largely a matter of porting between languages, not also porting between platform APIs?

I'm researching my options for the cross platform development of mobile apps. Most solutions take an approach in which code is shared across platforms. I'm instead looking for a pair of libraries written for Swift and Java that have identical (or nearly identical APIs), except for programming language.

That is, the framework provides an API that is independent of the underlying OS, as React Native, Flutter, and Xamarin already do. But instead of providing these frameworks in only one programming language, it provides the framework in multiple programming languages. The framework provides the class names, method names, property names, constant names. As much as possible, these names would be the same across the implementations for each programming language.

The developer then only has to learn one platform API -- that of the platform-independent framework. Let's call it the "abstraction API." After coding up the app for Android in Java or Kotlin using the Java/Android version of the abstraction API, the dev can almost mindlessly port the app to Swift, build with the Swift/iOS library, and have an iOS app. I say "almost mindlessly" because the Java code should be nearly identical to the Swift code all the way down to the particular abstraction APIs being called, except for differences in programming language syntax (and packaging).

The benefit here is that, for most things, the dev would only have to learn one platform API -- the abstraction API -- and just program the app in two different languages. This reduces the cross platform problem to largely porting between languages rather than also porting between platforms. The dev would only have to learn only one API and only design the app for only one API. Heck, it may even be possible to automate most of the port from one language on one platform to another language on another platform. Any code that must be native is easily made native because the dev is already coding natively.

You might call this "design once, code twice" or "code once, mindlessly port."

Of course, I could be missing something about this solution that makes it unviable. I realize that two sets of unit tests would still be necessary.

I'm looking for a single-abstraction multi-language mobile library that has already done this, particularly one that is well supported. What is available? I'm not sure that I will go this route, but it seems like one of the approaches I should be considering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment