Saturday, June 13, 2015

The Google Inbox story of Code Sharing

In the new world of variety of mobile platforms. the denominator now contains below programming languages

iOS => Objective C, and / or Swift
Android => Java or NDK 
Web => Javascript / CSS / HTML 5

Google tackled this problem and withe the Inbox app, it shares roughly 2/3 of its code across, Android , iOS and the Web 

These three platforms share most of the back end logic that powers the app, while the unique parts are mostly the user interface for each app. Google has built itself a good enough arsenel of cross compilers that it can write an app’s logic once on Android, in Java and then cross-compile to Objective C for iOS and Javascript for web. Java to Javascript is handled by the Google Web Toolkit SDK, which has been around for sometime. 

The Real enabler for Inbox is called j2objc, which as the name implies, covers the Java code meant for Android into iOS ready Objective C Code. 

j2ObjC is an open source project which Google went public last year. The project was used previously in Google Sheets, but the biggest usage is now in Inbox. 

In case of Google Inbox, a lot of shared code defines things like conversations, reminders and contacts. It also deals with the difficult tasks of network management and offline synchronization, where the app is used offline. Sharing the code is a big time saver, since it has to be written and debugged only once. It also makes the app consistent across both platforms. 

The tool does not convert UI pieces from Android to iOS, because that may lead to aweful UX. Google wants developers to write logic once in Java, transpile into other platforms and then make ui natively using the SDK for each platform. 

It is worth trying the j2ObjC having read this article. 

References:

No comments:

Post a Comment