Google Open Sources Java To Objective-C Translator
Written by Mike James   
Monday, 17 September 2012

Why would anyone want to translate Java to Objective-C? Because Java is the language of Android and Objective-C is the language of iOS.

This also explains why Google is behind the project, or does it? The more you think about it, the less it makes sense.

j2ObjC is a Java source translator to Objective-C. Notice that this isn't a cross compiler but a source code translator. Given that Java is an object-oriented language,and so is Objective-C, and both are block-structured, C-like languages, this doesn't sound so hard. The real problem isn't in the syntax, but in system calls and idioms.

 

j2objcbanner

 

The intention of j2ObjC is to allow Java to be part of an iOS application build. The Google Open Source Blog puts it like this:

"j2ObjC enables Java code to be part of an iOS application's build, as no editing of the generated files is necessary. The goal is to write an application's non-UI code (such as data access, or application logic) in Java, which can then be shared by Android apps, web apps (using GWT), and iOS."

It works by converting Java classes into Objective-C classes that use the iOS Foundation Framework. It claims to support most of Java 6 including exceptions, generics and threads. The project page describes it as between alpha and beta quality and assigns it an inital version number of 0.5.

It also includes the telling remark:

"Several Google projects rely on it, but when new projects first start working with it, they usually find new bugs to be fixed. Apparently every Java developer has a slightly different way of using Java, and the tool hasn't translated all possible paths yet."

This is a reflection of the fact that the translator is not converting one precise grammar to another. Also, there are a lot of untidy details to deal with the exact semantics of the code in both languages. Put simply, translating between high level languages is often harder than compiling to machine code.

j2objc is limited in its usefulness because it doesn't do the hardest part of the conversion job - converting the UI code. Google says that there are no plans to provide any sort of UI toolkit and the translator is targeted at converting backend code such as file downloaders and similar.

To run the whole thing you need a Mac running OSX with Java installed and Xcode. The translation can be made automatic using a build tool.

Google claims to need the tool for internal projects - I wonder what they could be?

 j2objcicon

 

More Information

j2objc project page

Related Articles

Objective-C Overtakes C++ in TIOBE Index

Sams Teach Yourself Objective-C in 24 Hours

The Top Languages of 2011

 

blog comments powered by Disqus

 

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.

 

Banner


Google Earth Pro Available Free
02/02/2015

Google Earth Pro, an enhanced version of Google Earth, used to cost $399 per year. As of now it is free although it still requires a Licence Key from Google.



Android For Work - A Developer Opportunity?
26/02/2015

Google has finally made a move on its promise of Android for Work, first announced at last year's I/O conference. It has a range of features that make Android more business-friendly, but there are som [ ... ]


More News

Last Updated ( Monday, 17 September 2012 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2015 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.