Cross-compiling Java to Objective-C for the iPhone

It seems that you can cross compile Java to Objective-C on the iPhone. I didn’t dig any deeper than that.
Here is the blurb for the technologies used:

The goal of XMLVM is to offer a flexible and extensible cross-compiler toolchain. Instead of cross-compiling on a source code level, XMLVM cross-compiles byte code instructions from Sun Microsystem’s virtual machine and Microsoft’s Common Language Runtime. The benefit of this approach is that byte code instructions are easier to cross-compile and the difficult parsing of a high-level programming language is left to a regular compiler. In XMLVM, byte code-based programs are represented as XML documents. This allows manipulation and translation of XMLVM-based programs using advanced XML technologies such as XSLT, XQuery, and XPath.

Apple’s iPhone has generated huge interest amongst users and developers alike. Like MacOS X, the iPhone development environment is based on Objective-C as the development language and Cocoa for the GUI library. The iPhone SDK license agreement does not permit the development of a virtual machine. Using XMLVM, we circumvent this problem by cross-compiling Java to the iPhone. Just like a Java application can be cross-compiled to AJAX, XMLVM can be used to cross-compile a Java application to Objective-C. The cross-compilation is also accomplished by mimicking a stack-based machine in Objective-C. Consider the instruction (integer remainder) that pops two integers off the stack and pushes their remainder after division back onto the stack. Using the following XSL template, the instruction can be mapped to Objective-C.

(via the PLT Mailing List)

Funny story about the Java compiler

I had always wondered if it was .NET alone that had inspired Sun to add generics to Java. Perhaps, as you will see here, there was a little more to the story!

On slide 24 I mention Philip Wadler and Martin Odersky. At this point in the talk I repeated an anecdote that Wadler told me. After they had done the work on generics, Odersky was hired by Sun to write the new Java compiler. He thought the generics were a good idea, so he put them into the compiler. The Sun folks always ran the compiler with the generics turned off. But they couldn’t rip out the generics completely, because they needed them in the compiler in order to get it to compile its own source code, which was written with generics. So they had to leave the feature in, and eventually they started using it, and eventually they decided they liked it.

Modularity in the Java platform

This presentation at JavaOne 08 could have been called “Features in Java 7 that people will love and wonder why it took so long to get them”.
The topic was JSR-277: The Java Module System.
Here is the 20K foot summary:

  • Give modules (roughly jars) first class language support
  • Provide support for module composition at deployment time

The result: no more Jar (aka DLL) hell and a lot of flexibility in terms of how you configure and deploy your system.

Closure Cookbook

At Java One 08 Neal Gafter gave the “Closure Cookbook” on Closures in Java; in particular the BGGA implementation that he is proposing as a JSR.
To sum up the presentation, it was about closures, in Java. In particular, it went into explaining what are closures and how you might use them. The tough, and more interesting part, is how you would use them in a statically typed language like Java.
It will be interesting to find out what percentage of the Java community will actually grok how to utilize closures. The impression that I got from the presenter is that closures will be limited to the library and API writers in all but trivial cases.

Java One 08 Keynote

Is Sun in touch with Java developers?
The entire keynote was spent talking about how developers are soon going to be able to write applets that run on a desktop, in a web browser, and also on a phone. We have had this for years. Whose idea was this?
The really interesting stuff in Java land right now is Java 7 features and concurrent programming with Java, but apparently none of that was worth mentioning.
The worst part of it all is that during the demo, the applet repeatedly crashed, and crashed, and crashed. The first Java program that I ever saw was running was an applet running in a web browser, in 1995.
13 years to get applets right? Come on Sun.

The benevolent dictator behind Java

There is a widespread belief among most Java programmers that while syntactic extension is indeed valuable, its introduction to Java would result in, among other things, human sacrifice, dogs and cats living together – in other words: mass hysteria. What I meant by “most programmers” is really just one Java programmer, Gilad Bracha.
Ostensibly Gilad is right on about this one. Macros will result in horribly unreadable code; but we all know that is not true. We have all seen unreadable code, in any number of languages that haven’t got macros, and even in Java (sorry Gilad). Macros in Java would ultimately expand into Java, which every Java programmer could read; so the idea that Java programmers couldn’t read the code is pretty far-fetched (not to say that folks wouldn’t use macros to generate unreadable code, which is entirely possible). Gilad knows this, though; he is a programmer, so I don’t really buy his marketing mumbo-jumbo on this one. So I wonder, what exactly his point is. It probably isn’t even fair to try and grok his point from the little excerpt provided in the link, but here goes anyway.
His point is that Java follows the approach of providing a lot of specialized constructs rather than a few general constructs on which to build new features; so macros would not a good fit (for comparison and contrast see “Programming languages should be designed not by piling feature on top of feature…”).
Simple. Succinct. Consistent. All the signs of someone who knows how to make a decision. Thanks Gilad!