Sunday, January 02, 2005

The Joys of Java

(Something from the slush pile, brought back by request. Some comments follow.)

As I'm writing this, I'm waiting for StarOffice to launch. I can tell because of the constant "ticka, ticka, BRRRT, bzz, bzz, ticka" from my laptop's hard drive. Obviously, powerful forces are at work. Mighty Java classes instantiating. Windows says there's about 51 MBytes of 'em in RAM.


What are they all doing?

I have this odd notion that it's the software equivalent of class warfare. Root classes spawn multiple children, which beget subclasses of data structures and pointers for generation upon generation, until finally some bit of executable code by accident (I can only assume) gets in the way of a stack pointer and in spite of everyone's best efforts is actually caused to run.

Big mistake.

Now, a mighty battle rages within memory space, with Windows (sitting on 95 MBytes) and StarOffice (with its 51 MBytes) battling it out with Mozilla (merely 21 MBytes) and a few mundanes like my email program (8 MBytes) locked in a territorial battle for my 128 MBytes of physical memory. Lazy Java classes are goaded into execution, forcing idle DLLs to be paged out into the virtual darkness. Windows responds with a batch of gratuitous Wm_event messages, causing every icon to repaint and grab back their individual chunks of real-space.

Finally, some compromise is reached, with the victorious Java classes executing in a fragile equilibrium with the remaining Windows Explorer DLLs, now forced to mutter plots of anarchy among themselves via backchannel APIs known only to Gates and God.

Then, more the fool I, do something truly stupid and try to scroll down on my document. Again, the screams of an anguished virtual memory manager, as it attempts the software equivalent of juggling a raw egg, a bowling ball, and a running chainsaw simultaneously. The Java virtual machine interprets my action as an unabashedly bourgeois attempt to associate its common working classes to a individualistic (and perhaps capitalist?) endeavor, and pulls out its big guns, as the display window shows the merest hint of the upper left corner of an embedded drawing object. It launches Acrobat.

Four minutes later, I declare defeat and go off to fetch a cup of coffee as my PC continues to grind away.

That's what it wanted me to do.... Java has won again.


---

Other than the intended laughs and occasional wry smiles signaling "been there, done that," I received a rather odd bunch of comments on this the first time around.

"But, you weren't using Java correctly," they go, "it works much better if there are ten or a hundred users sharing that one copy of Star Office, and that one JVM. Each user would hardly be using any incremental virtual memory then." Generally, these experts also add "You really shouldn't worry about memory utilization anyway. Memory is so cheap it's almost free, after all."

Absolutely, positively correct. Unfortunately, it's really hard to get 100 people logged into my laptop over a dialup connection in a hotel room, which is where I happened to be when I first wrote this, and where I had the profound pleasure of waiting twelve minutes for a rather complex document someone mailed me to open. As for memory, in the abstract it's gotten rather inexpensive, although in the particular, such as a memory upgrade for a 3 year old discontinued laptop that has exactly one proprietary memory slot, it can be quite expensive indeed.

So, let's agree that all tools have their purposes, and even a Swiss Army Knife becomes rather irritating when presented with a couple hundred drywall screws and a stack of two by fours.