In Which I Think About Java Again, But Only For A Moment
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:
- 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.
- 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.
- 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.
January 24th, 2007 at 11:23 PM
There was a brief time, during Java 1.3.1 on MacOSX, when MacOSX Java Apps were actually faster at quite a few things than “native” Cocoa Apps. This was because Java 1.3.1 was optionally accelerated with OpenGL, at a time when Cocoa’s 2D rendering wasn’t. (Cocoa’s 2D rendering still isn’t)
It was a forerunner to the current Sun efforts to use OpenGL in their pipelines. Java is not inherently slower, and importantly, is more than just a few dozen App/ UI classes, as Cocoa is. Cocoa is really good at making simple UI apps, like iChat, etc. fast. Its good at throwing dialogs up fast. But it doesn’t have the richness of the java frameworks.
Java’s gift to the world is sets of frameworks that encapsulate anything from network streams, to 2D rendering. There is no moment, of “time to switch to C”, as in Cocoa.
And course, as anyone who has actually tested this will tell you, java’s method dispatch is MUCH faster than Cocoas. Because of this, as many an experienced Cocoa person will tell you, people many times end up removing the Cocoa objects for speed later, to dodge the expensive dispatch costs. Also, Cocoa loads faster partially because Apple (rightfully so) chooses to load the libary during initial startup, and has spent alot of company resources to make sure its code sharing and code loading is optimal.
Cocoa suits Apples purposes well for things like iChat, or the System Prefs, etc. Its suits its purposes less well for things like Final Cut, or the Finder.
Java is good for doing large, functional cross platform apps, where you have a lot of real problems to solve, and want to use a modern language, with lots of object encapsulation to do it.
Its true, there are issues with Swing, but there is ALOT more to the Java frameworks than Swing. And when you write real Apps, that stuff is REALLY USEFUL.
Personally, I think for a small company coming to market, where you press a CD, or do a download, why not use java? Computers are VERY FAST now. So your developers time is what matters, and java is going to bring you to market, on Mac and Windows, ALOT faster than any other strategy, and in my experience (Ive shipped several java Apps for Fortune 500 companies to shrink wrapped shelves) Write Once , Run Anywhere works just fine. There are always little issues in the real world, but I’d rather deal with an activation weirdness because Apples java is slightly different than Sun’s Windows java, than a memory leak in my Cocoa App because its written in ObjC and C, anytime.
When I brought my last App up on Windows for the first time after coding it up on Mac, the ONLY problem I had we a byte swap issue in my file format, and that has NOTHING to do with java.
Thats the point for those of us that use modern languages. Programmer productivity. Not crashing. And object encapsulation throughout.
January 25th, 2007 at 7:29 AM
Binaldi,
Well, I guess it’s too bad that Java SE 6 has gorgeous font rendering and blazing speed. Because if you say that cient Java is dead, then it must be dead.
January 25th, 2007 at 9:01 AM
Oh, it’s absolutely dead.
I just started playing Poker online for fun, and PokerRoom’s Linux client is an Applet (i.e. the only client I can use right now; they also have standalone clients for Windows+Mac; not sure if those are Java as well, but it’s likely). PartyPoker also uses an applet, but I can’t login for some reason (I don’t think it’s my machine).
Funny. After so many years I finally turned Java support in my browser on again :-D
Another remark is here: http://weblogs.java.net/blog/davidvc/archive/2007/01/what_java_is_be_1.html
But I don’t know ThinkFree, so not sure how good it really is.
January 25th, 2007 at 1:12 PM
I really enjoyed reading this well-written and insightful perspective. Thanks.
January 25th, 2007 at 3:59 PM
So, you’re disappointed in AWT/Swing. That’s completely understandable. I’ve build Swing applications, and I agree. Anonymous inner classes to work around its single thread model, yuck! What you don’t mention is that Cocoa is single threaded as well.
I’m not sure what your role is at Apple with respect to Cocoa and its evolution, but it should be simple to use a NSBrower, Core Data, and Bindings to fill the first thing with data. It’s not. NSBrowser is full of bugs, Core Data is fine, but Cocoa’s single thread just kills the Bindings relationship. Too bad the documentation is not up to par with Sun’s and that Apple is commercially exploiting its developers.
I think these Java rants are a bit easy. When these issues have been addressed and Cocoa has gained enough market share for me to make a living out of it, poke me. In the mean time I’ll concentrate J2EE+Ajax.
(One last rant of mine: have you ever compared Eclipse with XCode?)
btw. I’ve used and am using Macs since ±1992 and will forever, just so you can value my opinion.
January 26th, 2007 at 8:00 AM
Two points:
(1) The success of Eclipse as a reliable centerpiece of Java development on the desktop will make plausible an increasing number of apps running on the rich client platform. If the playing field of Windows-Apple-Linux ever starts to even out, I think Java on the desktop to play a significant role.
(2) Emacs is still cool. Always looking for a more “modern” editor is no less geeky than sticking with a tool that I progressively upgrade with customizations that I carry from platform to platform and will always have at my disposal.
January 26th, 2007 at 9:37 AM
Reading through these comments again…developes just don’t get it. You all think about your perspective not the one’s who count…”The USERS”. Users are the adopters….users care about making their lives easier. They want to complete a task. What most developers don’t understand is people don’t think nor want to think in drop down menus or nav bars. They think in images and objects….not lists of data. What is happening or should say has been happening is that UI is not being thought of in terms of VO’s. This line of thinking is where the future lies in application development. Apples iphone is the perfect example..if you watch the demo they show albums in 3D allowing you to shuffle threw them like a home cd collection you select one then it flips over (just like a cd) and you get the song titles then you click one of those and it plays. This is more exciting more fun and more usable. After you use it once why would want to go back to text buttons, lists, datagrids? The problem most of you developers have is you think in terms of what you are given and what you have used in the past and most importantly you code or select technologies (JAVA) based on how your brain works. Java is fine for behind the scenes, but no longer for UI design, unless their is a major update coming.
This is where all applications will be going in the very near future….sorry to use the term, but this will be Web 3.0. People will choose objects or things that look and function like real world objects NOT lists and drop downs and datagrids and etc. Apple knows this and understands this. Thats why Ajax and Flex/Flash are taking off. Its like the Wii. Why is it so popular? Because you can navigate and use it the same way you would in real life. This goes out to all developers stop thinking in your languages terms and start thinking in real life terms in real object terms.
Most importantly get over yourself….why you don’t want to give up Java is because you didn’t learn any new skills or languages and now its your career thats going to go down if Java looses its relevance. And if you start with a new language now the power dynamic at your job will become unbalanced and you won’t be the lead or you won’t be the wise one everyone looks up to. Learn an RIA langauge or face whats coming to you….
January 26th, 2007 at 10:15 AM
J, you’re right that the user’s view counts, but there is no free lunch. It’s all basic economics.
For instance on the Mac there is only small demand (few users), and a small supply of developers, so many applications cost (or cost more than applications for the same purpose on other systems), but Mac users value their convenience over a little money.
Most Windows apps are written in some native toolkit (MFC?), because the market is big, and even an inconvenient language (for the developer) may be worth the higher development cost, if the end result is better.
Similarly, platforms like Mozilla, SWT, and Java focused on Windows as the major platform and look and run well on that system, because while a cross-platform app is supposed to reach all markets (not just one), it should of course run really well on the dominant OS.
And if a cross-platform toolkit runs well on Windows, why not use the cross-platform one? Especially for niche applications that don’t have large numbers of users it might be an advantage to use such a technology. You get another market for free (or little investment), and the technology might make development cheaper and the app more stable (Java vs C++). And cheaper development is good for the user as well, don’t you think?
Oh, and by the way, I know way more languages than just C and Java. It’s just that I consider Java by far the maturest and most well supported one (tools, libraries) right now. (languages like SML, Ruby or Lisp might be better for some domains or applications, but overall they don’t cut it for me.)
January 28th, 2007 at 9:30 PM
You don’t seem familiar with Java client work done in the last 5 years. You’ve never used Intellij Idea. Or Azureus.
People seem to write (or use) one crappy AWT app and write off Java’s GUI capabilities. Luckily we don’t see one crappy Win or Mac app and write off the OS. Meanwhile Swing has been invented for years and is now fairly mature (read: OpenGL optimized) in Java 6…
I grant you OSX GUI programming finally (after these many years) provided something as decently organized as Java’s GUI API’s. There’s nothing comparable in the Windows or Unix world to Java, API-wise even today.
And Applets are still dead, of course. No hope for a 10 MB plugin. Sun never got that part, that’s for sure. But there’s a surprising number of Java Web Start apps running around.
January 30th, 2007 at 5:26 PM
[…] A few days ago I was pointed to this very interesting post from an Apple engineer who had jumped off the Java bandwagon after getting a peek of Cocoa. […]
February 1st, 2007 at 11:09 AM
I found Steve Jobs’ iPhone/Java remarks very disparaging and I whish he could have found something to say that doesn’t piss off Java advocates.
I found Jens Alfke’s Java remarks insulting.
I used NeXTstep when it first came out and went to two NeXT conventions. Yah - I really loved the development environment. A few years ago I did some cocoa development and I still liked the overall development environment - and if all you ever have to do is write cocoa applications I think you are very fortunate indeed. I can write essays on the myriad things NeXT did right.
As soon as Java was available for download from Sun I was right on it. Sure I had no IDE but I found the language to be much better than Objective-C (and I think C++ is obscene) particularly in the area of memory management and threading. What particularly hooked me was the concept of write-once run-anywhere.
Now I work on a GUI application which works for both our Macintosh and Windows customers. Sure it doesn’t “look and feel” 100% like a Cocoa application, but most of our users cannot really tell the difference, even though it does take more effort to make our application look native on a Macintosh than on Windows. The point is I cannot think of any more effective ways to deploy the same GUI application on Macintosh, Windows, Solaris, and Linux and really open up your market opportunities for your product.
Most of the problems we have had on the Macintosh have been because Apple’s port of Java has been of a lower quality than Sun’s port of Java to Windows.
Finally, I find the combination of Java, Eclipse, Netbeans and other development tools to be an overall improvement over XCode. And who the hell cares about EMACS when you have Eclipse?
February 10th, 2007 at 1:11 AM
[…] I’ve read in a number of developer blogs I respect why Java sucks. These comments range from how Java’s UI tools suck to comments on how irrelevant Java is to Mac development. Apple has deprecated the Java to Objective C bridge in MacOS X v10.4, and the presumption that somehow third party software won’t be allowed on the phone means that Java must not be on the iPhone. […]
February 12th, 2007 at 8:33 AM
I work for a small ISV and am lead developer of our commercial Java GUI product. We have native Windows, Java and .NET interface clients. The Windows & Java UIs are very (some would say too) sophisticated interfaces (MDI, trees, splitpanes, toolbars, etc.).
Echoing what’s been said before:
* Ours is a niche product, licensed by 200 or so companies, and competition in minimal. So, we can “get away” with minor differences in our Java interface vs. native interface (mostly subtle nuances).
* We’ve layered our own web server/desktop synchronization code for the Java UI, so it has distinct deployment advantages (central, single-point maintenance) over typical native apps without resorting to things like Citrix. Had to do this because:
* Java’s perceived downfall was not so much due to interface issues, mostly due to; Sun’s ignorance of the importance of painless, seamless JVM/app install & update, Preponderance of “Java Developers” that hadn’t proper background to cope w/the sophisticated Swing UI, Sun’s propensity to break seemingly minor things in the API from release to release (e.g. from 1.2 -> 1.3 (?) JInternalFrames visibility default changed to not visible, several focus & modality issues that come & go, etc.). Essentially, it was & is not possible to expect any sophisticated Java UI that touches most JDK APIs to work properly from one JVM release to the next (without tweaking or even re-writing some behaviors, often subtle but critical).
* It was to our advantage to deliver a sophisticated interface to both Windows & Mac OS X platforms and as a small ISV this would *never* happen if it weren’t for JVM 1.2 & above (Swing, etc.). We would have been forced to forgo the OS X environment if we could not develop the Java interface the way we did (same, exact code/JARs for all platforms - very little platform-conditional code).
Bottom-line is that everything has advantages & disadvantages and nothing comes for free. You assess your requirements in the light of what is available.
February 16th, 2007 at 7:51 AM
[…] Entwicklung: In Which I Think About Java Again, But Only For A Moment: “My theory is that Java desktop apps succeed only in niches where UI design and usability don’t matter” […]
February 16th, 2007 at 10:26 AM
This gives me pause to think of Ajax frameworks like GWT or Wicket, where you basically code all the UI in Java. Are we bound to always repeat the same mistakes?
Web apps, not rich clients, but with Ajax the difference is smaller day after day.
February 16th, 2007 at 12:47 PM
Jens,
thanks for your thoughts - and I agree with them, mostly. However, I don’t see a better way to write cross-platform software than using Java.
But let me provide our own story — the (desktop) geometry software Cinderella (http://cinderella.de) we are writing (in Java) has had a predecessor, written in Objective-C on NextStep. We made the move from Objective-C to Java (back in 1996), because NextStep was just dead. There was no way to even compile the code on another platform, let alone run it.
Well, we could have waited another 5 years to resurrect the application on Mac OS X… no, not really. So with Java we do support Windows, we support Mac OS X, even Solaris or Linux, and we can do our development on the Mac.
Of course, it would be much easier if we were coding in Cocoa, but only for the Mac, and we just cannot ignore the people on the other side. That might change in another 5 years, but we don’t know yet. Java is now working for more than 10 years for us.
Tell Steve to port Cocoa to Windows, and I’d switch rather sooner than later.
February 18th, 2007 at 9:15 AM
I think the Apple people should get more realistic! Cocoa might be a good application environment for Mac-only applications. But if you have an application for a special purpose or custom application there is no alternative in using Java. Otherwise you would have to write it in .net which is Windows only! I have never met any customer that would pay for a Mac only app (at least here in europe, might be different in the US) and you would not find any Cocoa developers either. A programming platform is not merely a technical thing but also a kind of ecosystem with a market, customers, developers and so on.
This does not exist for Cocoa outside of Apple. And it never will for a proprietary, closed source, expensive technology. By the way, the only thing that sucks with Java is the Java implementation of Apple. It took a very long time to get usable. Apple should keep in mind: If there where not all those enthusiastic Mac supporters among the Java developers many Macs would have been eliminated from enterprises and universities. Hey Apple engineers: Do you really find satisfaction in providing a system only for entertainment software? The world of real-world problems, enterprise and research is the world of Java. If it is your goal to get the Mac out of this world and relegate it to be an iPod base-station then go on with such articles. Otherwise it should be a major interest of every Apple developer to have a good Java implementation on the Mac.