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 web app was created by using the GWT (Google Web Toolkit) cross compiler to convert the Java data model to JavaScript. GWT is an open source project created by Google in 2006 to allow Java programmers to create web apps with JavaScript. There have been speculations that Google might not be as interested in GWT as it once was - mainly because of its commitment to the Dart language. In 2012 Google made GWT a fully open source project. With its use in Inbox it seems that GWT is still a useful tool to Google and good enough to use for new projects. The UI of the web app seems to have been built using JavaScript, HTML and CSS.
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.
More InformationRelated ArticlesGoogle Open Sources Java To Objective-C Translator
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.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Monday, 24 November 2014 ) |