Category Archives: Java

The Java Language

Steve Jobs Hates Java

I finally read past the first few paragraphs in David Pogue’s [second iPhone FAQ](http://pogue.blogs.nytimes.com/2007/01/13/ultimate-iphone-faqs-list-part-2/), and I was a little surprised to see this:

> Jobs: It’s not worth building in. Nobody uses Java anymore. It’s this big heavyweight ball and chain.

As you can probably tell from my [last post](https://neror.com/2007/01/13/third-party-iphone-applications.html), I rather like Java, and I also rather like Apple. If that’s how Steve really feels about Java, it’s no wonder that Apple stopped supporting the Cocoa/Java bridge in OSX. I always assumed it was because of the wonderful open-source [Objective-C bridge](http://pyobjc.sourceforge.net/) in [Python](http://python.org/) (my personal favorite language) that Apple just couldn’t keep up with. Regardless of the reasons, it’s probably better that Apple chose to focus on Objective-C because the [improvements](http://developer.apple.com/leopard/overview/index.html) coming in Leopard are very exciting.

The Cocoa/Java bridge aside, I am disappointed that Steve still harbors the ancient misconception of Java being big and slow. This has not been the case since Java 1.4 was released, and Sun has made great strides in performance in its subsequent releases. From my personal experience working with Java both on the web and on the desktop, the platform is more than capable of performing at a high level.

This reminds me of a product I meant to tout in my previous post: [ThinkFree](http://www.thinkfree.com/common/main.tfo). It’s a Java applet based online office suite. ThinkFree is a great example of how powerful applets and Java are. Sure it takes a minute to download the applet the first time, but then it’s cached for future uses. It really is Word/Excel/PowerPoint in a web browser, and it it beats the pants off of Google’s office suite feature and performance wise.

Well, I haven’t written a lick of Java code in 4 months, and I probably won’t for quite a while (at least until the iPhone comes out ;)). So, this is probably my last post about Java as my knowledge of the language and the platform will become stale pretty quickly. I hope to write more about [Python](http://python.org/) and [Django](http://www.djangoproject.com/) in the coming year, though. My current project makes extensive use of them, and I’m having a blast working with them.

Third Party iPhone Applications

*Disclaimer:*

*I wrote this before I read [David Pouge’s iPhone FAQ ](http://pogue.blogs.nytimes.com/2007/01/11/the-ultimate-iphone-frequently-asked-questions/) which mentions that the iPhone’s Safari will not run Flash or Java Applets. D’oh! Since I spent some of my morning on Friday writing this post, i figured I’d publish it anyway. The benefits of Java Applets apply to web apps whether or not they target the iPhone. So, hopefully, there’s some value in here.*

*Update:*

*It looks like Pouge has recanted the comment about the iPhone’s Safari not supporting Flash and Java. It’s the first item in [his second FAQ](http://pogue.blogs.nytimes.com/2007/01/13/ultimate-iphone-faqs-list-part-2/). This post might be relevant after all!*

[Todd](http://www.ditchnet.org) wrote [a post](http://www.ditchnet.org/wp/2007/01/11/the-only-way-to-write-software-for-the-iphone/) Thursday on his blog that piqued my interest.

>The only way to write software for the iPhone that I can imagine is via web applications.

>…

> Are Java applets once again an attractive option? Or will devs and users prefer HTML/CSS/JS/Ajax?

I’m of the belief that Java applets have been given a bad rap because of their early history as slow-performing, memory-hogging toys in the 90’s. The truth is that Java is now a very powerful desktop platform, and applets allow developers to use the full power of that platform in a “web app.” I don’t believe that applets will experience a renaissance in the average data driven Web 2.0 app, especially with the advances being made in the DHTML/Ajax/etc. world, but I think Todd has an interesting point with the iPhone.

If the iPhone runs a full Java VM, “desktop class” applications are only an applet away. Deployment is simple. Pushing updates is trivial. Applets are also extremely simple to package and deploy. What seals the deal for me is event handling, drawing API, networking, and filesystem access for offline and advanced usage.

I’ll admit that I don’t have a bunch of experience with DHTML, but I wonder how DHTML compares to Java when it comes to handling events, especially the multi-touch gestures? 2D drawing is also very easy with Java, but this might be a toss up due to Safari’s support of the [<canvas>](http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/Canvas.html) tag. My gut tells me that Java2D is more full featured and easier to use, but I have no evidence or experience to back that up. If the iPhone really runs OSX, then Java also has [jogl](https://jogl.dev.java.net/) to do 3D OpenGL drawing. I’m drooling just thinking of multi-touch and 3D. I’m sure you couldn’t do a whole lot with the limited processing power of a small device, but there are still some possibilities there.

Filesystem and network access is a completely different story. Provided that the applet is signed, and the certificate accepted by the user, the applet has the same rights as any other desktop app when it comes to reading and writing files to the filesystem. I don’t know of any equivalent in the DHTML world. The only thing close that I know of is the [great work](http://codinginparadise.org/weblog/2006/04/now-in-browser-near-you-offline-access.html) done by the [dojo toolkit](http://dojotoolkit.org/) team. The dojo.storage API only allows you to store data in the client in a specific location, though. It is just for offline storage, and it’s not a real filesystem API. It also requires Flash to be installed and enabled on the client. A Java applet would have access to all of the preferences, pictures, video, contacts, music, etc. stored on the phone. This is a big difference, and opens up many other possibilities.

Applets also have all of Java’s networking libraries at their disposal. You can emulate some of this functionality with XMLHttpRequest, but not all. One example that comes to mind and ssh client, or maybe a VNC server over Bonjour (although I don’t know why you’d want to do that). Obviously, there is a lot more at the developer’s disposal here.

At this point, this is all speculation. I don’t know what kind of tools will be available for the iPhone. If Apple is not going to provide the tools and rights for developers to write real “desktop class” applications for the iPhone, the developer community **will** find a way to do it on their own. [It’s a moral imperative](http://imdb.com/title/tt0089886/quotes). I’m really interested to see how this all comes out.