SIDEBAR
»
S
I
D
E
B
A
R
«
In Which I Think About Java Again, But Only For A Moment
January 21st, 2007 by jens

It’s amusing how Steve Jobs’ remarks disparaging the idea of Java on the iPhone have ignited controversy. His point was, obviously, that the iPhone’s browser won’t support Java applets; which is a no-brainer because applets were killed dead-dead-dead by Flash and Ajax. But this seems to have riled up everyone who still cares about non-server-based Java, leading to the weird situation of seeing “Java” and “Mac” in the same sentence again*. Apparently some people still cling to the glorious dream of writing cross-platform GUI applications, waving tattered “Write Once Run Anywhere!” banners and clutching ‘Little’ Red Books with Duke’s picture on the front.

Flashback

Me, I defected long ago. I’m another of those Apple Java engineers who dropped out. I spent five years as a raving Java fanboy, but I gave up after optimizing AWT, implementing drag and drop, and trying to make 1,200 pages of crappy APIs do the right thing on the Mac. Then I took a one-week Cocoa training course, and wrote the first prototype of iChat.

Desktop Java never worked because Sun tried to build their own OS on top of the real OS, duplicating every API and feature. This led to terrible bloat, making every app as heavyweight to launch as Photoshop. Worse, the GUI portions of the Java platform are awful, because Sun is a server company with no core competency at GUIs. The APIs are too clumsy to code to, and compared to any decent Mac app, the results look like a Soviet tractor built on a Monday.

Why Cocoa Pwnx0rz

That Cocoa training class was, as I’ve said before, one of the biggest eye-openers of my career. It was so damn easy to build beautiful, functional applications that I walked out feeling like I’d climbed into some giant mecha robot and could now lift huge girders with a wave of my pinky.

Three important things you need to be able to make apps with great human interfaces:

  1. You need to lay out the user interface components visually, by hand, with total control over where they go. Automated LayoutManagers don’t cut it. A corollary of this is that you can’t move a UI layout from one platform to another and have the computer make everything fit. Computers don’t lay out interfaces by themselves any better than they can translate French to English by themselves.
  2. You need to be able to change the UI around really easily during development — after user testing, or a Steve Jobs encounter session — even after you’ve attached a lot of code to it. That means no RAD tools that write code for you, because once their code mingles with your code, it gets hard to disentangle. Instead, the UI should be described with data, like an Interface Builder “.nib” file.
  3. Changing the UI around also requires being able to change your own UI code easily. As the Ruby and Agile Programming zealots always point out, strict type checking can really get in the way of this. Writing endless Listeners and Adapters and inner classes was one of my least favorite parts of Java programming. Objective-C and AppKit have a good approach, letting you use type-checking where it’s important but leaving looser connections at the UI level so you can plug and re-plug connections easily.

My Theory

My theory is that Java desktop apps succeed only in niches where UI design and usability don’t matter: development tools and enterprise software. Programmers expect things to be crude and complicated: anyone who’ll voluntarily use ‘vi’ in the 21st century will put up with anything**. And the poor users of enterprise software don’t have a choice: they have to run the damn app no matter how awful it is, because it was selected by an MIS department that could care less about usability.

Footnotes

  • Not that this controversy has anything to do with the Mac. The iPhone is not a Mac, the Mac still runs Java, and no one is talking about taking it away.

** And that goes for ‘emacs’ too (with apologies to my boss). I thought emacs was really cool, in 1986. That’s when it was really cool to have a DEC VT220 terminal in my dorm room with a 9600 baud connection to a VAX running BSD 4.3. Also, I listened to Depeche Mode.


77 Responses  
  • Michael Tsai - Blog - Apple and Java writes:
    January 21st, 200712:08 PMat

    […] Jens Alfke: […]

  • fluffy writes:
    January 21st, 20072:34 PMat

    The only reason I like Emacs better than any other editor right now is it’s the only one which does The Right Thing for indentation, namely pressing “tab” on a line reapplying the auto-indent rule to the line. XCode comes so frustratingly close to doing The Right Thing but it misses the mark (also I can’t get it to indent my switch/cases the way I like, and its parameter auto-completion is another close-but-no-cigar thing though it’s not like I use that in Emacs either).

    (By the way, I can’t seem to get your OpenID stuff to use the OpenID server on my site. It’d be nice if WordPress gave less obtuse error messages than “cannot find server” though.)

  • John C. Randolph writes:
    January 21st, 20074:18 PMat

    I generaly described the experience of learning NeXTStep as akin to removing a straitjacket.

    BTW, EMACS *was* really cool back in 1986. These days, not so much.

    -jcr

  • James Duncan Davidson writes:
    January 21st, 20076:15 PMat

    I still listen to Depeche Mode, but yes, EMACS and vi can go jump. I still use ‘em a bit when I’m on the far end of a SSH connection, but that’s the only time. Otherwise, modern text editors all the way. TextMate.

  • rodney writes:
    January 21st, 20077:04 PMat

    Kinda takes you back… I learned emacs on a BSD VAX while listening to Depeche Mode in about 1985. Now, I only use emacs or listen to D.M. when I’m feeling nostalgic.

    You’re dead on about the Enterprise being stuck in 1986, too. I’ve worked at more than one place where people look at you with contempt if you mention that just maybe we could at least think about moving into the 1990’s and use an IDE.

  • bonaldi (LJ) writes:
    January 21st, 20077:25 PMat

    Desktop Java never worked because …

    The thing I love about the iPhone/Java storm is that it’s definitively put desktop Java into the past tense. There’s just no hope for it, now.

  • Mihai Parparita writes:
    January 21st, 20077:42 PMat

    I don’t think the iPhone/Java discussion was about desktop applets but about J2ME apps that run on other phones. Phones are the one platform where Java apps are still being used by consumers in large numbers. Not sure whether this is due to any merits of Java or because it’s the only reasonable API available, but I’m guessing this was asked as a way of seeing just how closed the iPhone platform will be.

  • George writes:
    January 21st, 20077:43 PMat

    When people ask about “Java” on iPhone, they are refering to the support of Jave 2 Micro Edition J2ME support.

    There are many many J2ME developers around the world that develop mobile application/games for mobile phones. iPhone support of J2ME will be a huge plus. People are looking for easy way to porting their J2ME app to iPhone. They don’t want to see Duke dancing on their screens.

  • fluffy writes:
    January 21st, 20077:49 PMat

    J2ME is the best available open mobile platform but that’s only because it’s the ONLY open mobile platform. It’s pretty terrible. Sadly, BREW (the other widely-available one, though only on Verizon phones) is even worse.

    Neither platform is really oriented towards general-purpose applications; in terms of built-in widgets they’re basically limited to a tiny class of applications (messaging, stock tickers, etc. - actually BREW has a built-in “stock ticker” primitive), and really have the same problems as desktop Java that Jens was getting at. The only place where MIDP has kind of taken off is on mobile gaming, and realistically, games have only thrived on MIDP in spite of its problems. Until MIDP 2.0 came around, graphics was basically an afterthought, and MIDP 2.0 hasn’t gotten enough widespread acceptance for games to really be coded to it in mind, so developers still need to basically support MIDP 1.0 anyway, which means either developing two entirely different codebases or just using MIDP 1.0 primitives.

    It’s all a big mess.

  • aterreno writes:
    January 21st, 20078:02 PMat

    I think that also the Java MIDlet are dead and, even if I was Java ME programmer I see this technology completely awful on the phones. I wrote some days ago an article on my blog about this My current point of view on J2ME

  • Matt McCowan writes:
    January 21st, 20079:05 PMat

    rodney wrote - I only use emacs or listen to D.M. when I’m feeling nostalgic.

    For a second, I thought you wrote I only use emacs to listen to D.M. when I’m feeling nostalgic., which given emacs could be just as true.

  • Rhonabwy » Excellent description writes:
    January 21st, 200710:25 PMat

    […] Regarding attempting to write desktop apps with Java: compared to any decent Mac app, the results look like a Soviet tractor built on a Monday. […]

  • Karl Gretton writes:
    January 21st, 200710:32 PMat

    Hmm…I also still listen to Depeche Mode and use vi whenever I’m on an SSH connection.

    I agree about Java on the Desktop. Apple did a great (overly complicated) job with their WebObjects Java Client but Ajax and Flash/Flex have surpassed them.

    I think that trying to do a decent UI with Swing or even SWT is going to drive a rational person insane. Perhaps all Java Desktop Developers are or will become insane?

  • jellyBeans writes:
    January 21st, 200711:46 PMat

    “His point was, obviously, that the iPhone’s browser won’t support Java applets”

    Hmm. How do we know exactly what Jobs actually thinks of Java in general, as opposed to just for the iPhone? Do you have any further insight/info or are you surmising?

    Also, is there any info you can provide at this point regarding widget development for the iPhone? For example, can WebClips (just limited to JavaScript) be “downloaded” to the iPhone? Where would they reside?

    I know the closed iPod environment has worked for Apple, largely because the realm of potential apps for digital music is relatively puny compared to the universe of potentially useful apps for a device that can act as a phone, web client, PDA, etc. Is the thinking at Apple such that the company believes it can fulfill this all by itself? On this issue, have we heard all we will from Apple?

  • Adrian writes:
    January 22nd, 200712:23 AMat

    I’ve got to agree with most of this except for two things:

    1. TextMate does rock, but I still use gvim for most of my text editing needs. I wouldn’t use pure vi though.

    2. I find it hard to take your views on good UI seriously when you use a blog theme that puts small serifed text in mid orange on a light patterned orange background. Your whole site is like one giant captcha pattern :)

  • Roland Fines writes:
    January 22nd, 200712:44 AMat

    Java is a platform, but it is also a Programming Language. As such it is much more useful than Obj-C.

    - Various programmers know Java. (almost) Only Mac developers know Obj-C. Therefor a tremendous effort is required to support Mac OS X,
    - Obj-C is only starting to reach Java in terms of ease of use with version 2.0,
    - Java dev tools are a bliss. When I tried to write my first Obj-C app, I banged my head so many times against the walls that the roof feel on me. I could not easily spawn a new thread without writing hundreds of line, auto-completion was useless, and writing .h files for every class was a hell to maintain. The end result was unstable and unmaintainable. It felt like “back to the dawn of programming”.

    I agree with you on the UI part, but the Java-Cocoa bridge was just that. You could write platform independent code for you model classes, and keep the View and Controller platform specific.

  • a crank’s progress :: links for 2007-01-22 writes:
    January 22nd, 20071:31 AMat

    […] In Which I Think About Java Again… I don’t know much (anything?) about programming but “the results look like a Soviet tractor built on a Monday” doesn’t require a lot of coding smarts to understand. (tags: java programming software design) […]

  • Rolf writes:
    January 22nd, 20072:14 AMat

    Well, I do write cross platform GUI apps in Java, and moderately successfully I believe.

    I object very strongly to being tied into one platform. I refuse point blank to develop GUIs in C++/MFC/.Net, and I refuse to use Cocoa for exactly the same reason. I’m sure Cocoa is excellent technology, but if it doesn’t run under Windows forget it. And if I can’t develop GUI apps in Java then frankly, it’s the Mac that will suffer, as with a 95% share it’s Windows I will have to focus on.

    When people talk about “Java” on the iPhone or elsewhere, remember this can mean quite different things:
    a) Java as a non-GUI platform (typically for server processes)
    b) Java applets in a web browser
    c) Desktop Java
    d) Embed micro-Java (J2ME) for writing mobile phone games and so on
    e) JavaScript, which has nothing whatsoever to do with Java other than the name

    The first three are quite heavyweight - for a mobile device - so Jobs is right that they’re not appropriate for the iPhone, but that’s what J2ME was developed for. Apple have already said they don’t want to open up the iPhone to 3rd party apps they have no quality control over, so omitting Java is fair enough. That doesn’t mean the other three aren’t perfectly valid technologies though (except personally I’ve always thought applets are a bit of a waste of space).

  • toniBlog» Blog Archive » My personal point of view on the iPhone writes:
    January 22nd, 20072:18 AMat

    […] Is important to install applications? Well, yes. It is, but, is Java necessary inside the iPhone? Maybe not. Maybe some nice widget and a good browser web is all what you need here. Read my post My current point of view on J2ME if you’re still sure that there’s space for J2ME on the mobile phones. I read also this post about Java and Phones in one comment one guy says: “J2ME is the best available open mobile platform but that’s only because it’s the ONLY open mobile platform.” […]

  • Ulrich Hobelmann writes:
    January 22nd, 20075:12 AMat

    Just a few things. Until last week, I was a Mac user (for more than two years). I’ve used Cocoa. I liked it, for the most part.

    But, lets sweep aside that RDF for a minute. Have you had a look at Java recently, on Windows or Unix/X11 ? Do you know how fast applications start up, and how *nice* they look with a Windows or Gtk look+feel? Have you had a look at NetBeans? No, it’s not IB + nib files, but it’s a very decent GUI builder with an initComponents() method (as the Black Box), and it’s completely cross-platform.

    Yes, on the Mac everything foreign (=non-Cocoa) looks a bit like crap (except maybe NetBeans, which is astoundingly pretty), but I’m not sure that other frameworks are to fault for that. When your GUI is all rounded and aquay, everything that’s more sober and edgy and maybe gray looks a bit out of place. Plus that menubar thing.

    I don’t want to rant about Cocoa, but let’s just say that you still have to do a lot of hand-coding, which is not too different from Swing, IMHO (I don’t get why people keep bashing Swing; it never seemed much worse than other frameworks to me, except for the don’t-have-to-use-it Metal/Ocean look).

    Desktop Java ain’t all that bad, once you look at it (and rapidly improving, while Apple tries to take common Java features and put them into ObjC). And just like Ruby on Rails, Groovy, or .NET, Cocoa is no panaceum, as far as I’ve seen it.


»  Substance:WordPress   »  Style:Ahren Ahimsa