|How Google Does Multi-Platform In Inbox|
|Written by Mike James|
|Monday, 24 November 2014|
One of the biggest problems programmers face today is making a single code base work across a range of systems. How a giant company like Google solves the problem is obviously going to be interesting.
Google has just created a new email client called Inbox. At the moment it is being tested by invitation only, but the Gmail blog has revealed its architecture to everyone.
The problem the developers had to face was how to build three "native" apps - one for the web, one for Android and one for iOS. Obviously they wanted to avoid writing the same app three times. They quickly ruled out the "hybrid" native/web app using something like Cordoba for reasons of efficiency. The only option was to create three native apps that shared as much of the core logic as possible.
The Android app seems to have been the main development project and it is the only one of the three that is a native app built with the "native" tools, i.e. Java and the Android SDK.
The data model was written just once in Java and the Android UI was built on top of this. The data model provided abstractions of things like Conversations, Reminders, Contacts and Labels.
Having a complete Android app, it only now remained to port things across to the other two platforms.
The iOS app was created in a similar way, but this time using J2ObjC. This Java to Objective-C translator is another Google open source project that is not as well known as GWT. It doesn't make any attempt to translate UI code so, as for Android, the UI was written on top of the data model in Objective-C.
The only special attention the Java code needed was the addition of @WeakReference annotations to allow Objective-C, which uses reference counting, to deal with reference cycles in the Java code.
The team claims that overall something like two thirds of the code is shared between the three apps and clearly this makes the exercise well worthwhile.
There is something very irritating in the way that the UIs have to be written from scratch in each case. Surely we can find a way to build a tool that does the entire job and only leaves the programmer to tweak the UI to make it look 100% native.
To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin, or sign up for our weekly newsletter.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Monday, 24 November 2014 )|