J2ObjC: Google’s Shared Logic for iOS and Android Apps

J2ObjC is a “Java to iOS Objective-C translation tool and runtime”. Google uses it to maintain a cross-platform shared codebase for its mobile apps; internal logic is written once (in Java) and ported to Objective-C using this tool. But it’s only for non-UI code. Here’s why, from creator Tom Ball:

It’s regularly asked why J2ObjC purposely avoids translating UI code; after all, wouldn’t it be wonderful if a tool existed where a developer can drop in Android source and out pops an iOS app? Our usual response is that world-class apps need user interfaces that are tightly integrated with each platform, and that common-denominator attempts to span platforms provide degrades user experiences. As I found when working on Swing many years ago, customers notice the smallest deviations from a platform’s UI standards and generally find them off-putting. But non-compromising UIs are just one of the reasons we focus on translating shared logic.

I wasn’t aware of this; my thanks to Google’s Ray Cromwell for bringing it to my attention. What I find interesting is that Google is (wisely, in my opinion) hand-crafting their iOS UI code for performance reasons and to avoid all the well-known pitfalls of cross-platform UI code, but they’re using their cross-platform “Material Design” visual style. That is, they’re writing native iOS code to create Google-styled apps.

Tuesday, 4 November 2014