Why the iPhone puts Java into the past tense (apparently)

In Which I Think About Java Again, But Only For A Moment [smallcool].

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.

He almost makes me want to get a Mac, ditch BSD and emacs, and start writing Cocoa apps – except that then life would just be too darn easy, and I’d never hear the end of it from TR (or Bash, probably).

It’s always somewhat depressing, or at least downheartening, to see someone like this tell me I shouldn’t be using emacs. It always makes me wonder if, maybe, they’re right – maybe out there there’s an editor that’ll do everything emacs does for me, but somehow nicer, more productive. Usually, as far as I can tell, that means the editor does IDE-like things such as autocompletion, code browsing, etc. – and yes, that’s stuff I just don’t use when coding. But gosh darn it, I’ve tried a lot of editors and nothing has ever come close, for me, to the feeling of power and (welcome) flexibility emacs gives me. Effortlessly editing multiple files in multiple split views in multiple windows (across multiple virtual desktops), powerful and easy regexp and macro capabilities, and (as one of the commenters on the linked article says) just doing The Right Thing with indentation in Python, Java, C, Haskell, … So the downheartening aspect is the tantalising feeling that there’s something else out there I should be using, but I just can’t find it! Of course, not using a Mac probably doesn’t help me, here. ;-)

I haven’t listened to Depeche Mode for a while, mind…

Oh, and here‘s another “Java is rubbish” story (comparing EJB lines of code with python/django) from the same source.

7 Responses to “Why the iPhone puts Java into the past tense (apparently)”

  1. January 24th, 2007 | 3:02 pm

    Funny – I keep trying to go the other way, but I keep running into things that I can’t work out how to do in EMACS, and keep running back to jEdit.

  2. Andy
    January 24th, 2007 | 4:02 pm

    Well, you could both use TextMate and have the best of both worlds :) Of course, you need a Mac to run it.

    I agree totally with the quoted comment about Java – and now with the iPhone it does seem that Apple is bringing Cocoa goodness to the mobile platform

  3. January 25th, 2007 | 4:05 pm

    Bah! I was going to point to http://macromates.com/ and say: “Voila!”, but Andy beat me to it.

    <zmobie>Join us….</zmobie>

  4. January 25th, 2007 | 4:30 pm

    I realised last night that the killer feature of emacs, for me at least, is the way I basically never have to use the mouse – I can do pretty much everything with the keyboard. This is a big win because the mouse slows you down enormously. (The only exception I can think of is if I want to copy from emacs to another window, where sometimes it “just works”, but sometimes I need to mark it with the mouse, it seems. Of course, that’s probably X’s fault for having a crappy copy/cut/paste model.)

    In particular, emacs handles copy/cut/paste beautifully, which is handy because, well, I do those things quite a lot! :-)

    To mark a block for copy/cut you go to the start, hit Ctrl-Space (or whatever you’ve set, but that’s the default), then move to the end, and there’s your block. This is less work than the more common/modern method (move cursor to start, hold down shift while moving to end), and gives you more freedom to, for example, hit Ctrl-S to search incrementally for a block of text – your marked area expands behind you as you search. Very powerful, very fast. There are also shortcuts for cutting the entire line/paragraph/etc you’re on, or the rest of the line/paragraph/etc, which help too. Oh yes, and the ring buffer: After hitting Ctrl-Y to paste (“yank”) the result of the last copy/cut, I can then repeatedly hit Alt-Y to (instead) paste in from older copy/cuts, eventually cycling round to the most recent one again; the size of that buffer is user controlled, of course.

    Of course there are plenty of other things I love about emacs, but if I think about what I don’t enjoy most about other editors I’m occasionally forced to use, I’d say the Total Keyboard Control is at the top of the list.

    Now someone can make me look stupid and neanderthal by telling me Textmate, XCode, JEdit, etc. can do all these things too! :-)

  5. Slava Pestov
    January 26th, 2007 | 8:29 pm

    To select text in a similar way in jEdit, press C+t a at the beginning to set a marker ‘a’ (or any other letter), then go to the end, and press C+u a (select to marker).

    One can record a macro which does “Select Line, Copy”, and in fact macros for copying and pasting lines come with the distribution.

    Another way to cut/paste avoids to clipboard altogether, you simply delete the text you want to move, then move the cursor to the destination, press C+e C+y, and use the arrow keys to select among recently deleted snippets.

    You also get multiple clipboards (called registers), C+r C+c a, C+r C+v a, etc.

  6. JJ
    January 27th, 2007 | 8:00 am

    The reason there is no Java on the iPhone is because Java is from Sun, and iPhone is from Apple.

  7. January 27th, 2007 | 9:25 am

    Slava: sounds like jEdit’s got quite a nice approach, then – quite emacsy! :-)

    I realised the other thing I love is its “fill-paragraph” feature, which basically indents/word wraps a paragraph or region and which I use constantly when coding, because it just really helps me write code with consistent indentation and no overlong lines.

    That feature became annoying with WordPress, since it honours linebreaks (turns them into <br /> tags), so writing posts in emacs became a pain — but of course, someone’s written “unfill” macros! :-)

    I got them from here, and they are:

    (defun unfill-paragraph ()
      "Unfill the current paragraph."
      (interactive) (with-unfilling 'fill-paragraph))
    (defalias 'unwrap-paragraph 'unfill-paragraph)
    (defun unfill-region ()
      "Unfill the current region."
      (interactive) (with-unfilling 'fill-region))
    (defalias 'unwrap-region 'unfill-region)
    (defun unfill-individual-paragraphs ()
      "Unfill individual paragraphs in the current region."
      (interactive) (with-unfilling 'fill-individual-paragraphs))
    (defalias 'unwrap-individual-paragraphs 'unfill-individual-paragraphs)
    (defun with-unfilling (fn)
      (let ((fill-column 10000000)) (call-interactively fn)))

    One more emacs trick… X Window has a pretty broken copy/paste mechanism, and in particular you middle-click to paste. This is a real pain in the neck when pasting into the middle of text, because you have to position the mouse in exactly the right place before clicking – wherever the cursor is, it will jump to your mouse position when you click, but before the paste. You can turn this off in emacs with:

    (setq mouse-yank-at-point t)

    … so the paste happens at the cursor, and the cursor doesn’t jump — and oh, how I wish I could do the same in text boxes in Firefox. :-(

    JJ: true (although Java’s being open sourced), but not the point. It’s not about why Java’s not on the iPhone; it’s about what Java’s absence from the iPhone says about the future of Java.