Java to Objective-C (J2ObjC) is an open-source advanced software engineering tool from Google used to translate Java source code to Objective-C for the iOS platform. J2ObjC was created so that developers can avoid coding twice by writing all business logic and data model handling in Java and then converting it to Objective-C. Specifically, J2ObjC can be used for iPhone and iPad applications and is meant to be used by experienced developers who have strong knowledge with Java but not necessarily Objective-C.
Google first launched J2ObjC with Google Sheets – the spreadsheet that is part of Google Docs – but J2ObjC is currently better known for its usage with Google Inbox, the modernization of Google’s Gmail email product. Available across Android, iOS, Chrome, Firefox and Safari, development of Google Inbox faced a problem often encountered when developing an app across multiple platforms: multiple clients using multiple programming languages. J2ObjC enables Google Inbox to share around two-thirds of its code across Android, iOS and the web, reducing development and debugging time since code is written only once. J2ObjC does not contain a cross-platform UI-toolkit however so developers must create it natively to ensure a high quality user experience for the specific language.
[See Also: What’s New in Java 8]
J2ObjC is beneficial to developers who are not as proficient with ObjC as they are with Java but wish to reduce coding time significantly with multi-platform development. J2ObjC enables Java code to be part of an iOS application’s development without editing of the generated files. A typical use for J2ObjC involves a developer writing the non-UI code such as data access or application logic in Java. The code is then shared with web applications using Google Web Tools and also with Android apps and iOS apps.
Perhaps J2ObjC’s most obvious advantage is that it reduces code duplication leading to shorter development times and fewer errors. J2ObjC forces developers to strictly follow MVC architecture, separating business logic and UI development. This enables the UI to be developed independently of the core regardless of what stage it’s at, leading to improved workflow and better developer resource allocation. J2ObjC is supported and promoted by Google itself, which why it clearly entrusted Google Inbox development with it. J2ObjC offers a strong online community for help and troubleshooting and as an open-source tool, its functionality improves over time.
While the J2ObjC tool is generally considered to be straightforward to use, it does require strong development skills on the part of the developer utilizing it. J2ObjC doesn’t enable the customization of generated code – specifically method names and for optimization purposes – which may be an issue for users. J2ObjC requires long compile times on iOS and is generally not suitable for a largely UI-based project. J2ObjC requires that proper resources are allocated to core development to avoid bottlenecks.
[See Also: Using Drools vs. Esper Rules]
The biggest barrier to adoption for J2ObjC tends to be defining where and when to use it and as with many new concepts, gaining acceptance in the enterprise to begin with. The benefits of J2ObjC make it more cost effective than coding natively for each platform, making its adoption beneficial to developers working on cross-platform projects.
Everything you need to know about outsourcing technology development
Access a special Introduction Package with everything you want to know about outsourcing your technology development. How should you evaluate a partner? What components of your solution that are suitable to be handed off to a partner? These answers and more below.