I wrote this before I read David Pouge’s iPhone FAQ 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.
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. This post might be relevant after all!
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> 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 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 done by the dojo toolkit 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. I’m really interested to see how this all comes out.