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


PiBot - Not Quite The Pilot You Were Expecting
21/09/2014

Take a small humanoid robot, teach it the rules of flying and you have an auto-pilot that can pilot any plane with standard controls. 



Lennart Poettering - Open Source Not A Nice Place
07/10/2014

In a blog post Lennart Poettering, the main force behind the controversial systemd Linux configuration system, explains that any dislike of his software spills over to him personally - and not just ha [ ... ]


More News

Last Updated ( Monday, 17 September 2012 )
 
 

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