Thursday, August 28, 2008

The Need for Better Interfaces (Human to Computer)

I can't help but believe that there has to be a better way. There has to be more options...

I talking about the I/O options to my computer. Here are a couple of recent stories that will hopefully bring context to what I mean.

Gestures on the Mac
Recently I purchased a new MacBook Pro. You know, one of the new Macs with the multi-touch capabilities. The idea is that if you use one finger you move the mouse, if you use 2 fingers it scrolls (and not just up and down), if you use 3 fingers then it depends somewhat on what application you are using, but generally it means go back or go forward depending on the wave of the hand. This is just awesome stuff and here is what happened to me.
First, the back and forth action of 3 fingers worked in Safari and in finder.... but not in Firefox. I was a little more than dismayed. Generally preferring Firefox, I found myself using Safari more in order to use the gestures. I really wanted this new feature in all applications. Eventually the shiny new toy lost some luster and I mostly use Firefox again. The consequence... sometimes I forget the gestures work in the finder... and I know that I would use it all the time if it always worked. In other words if the bell always rings and I can trust it, I will salivate. And I want to.

A PC with No Gestures
So eventually I found myself working again on another laptop. Man did I look like an idiot for a few minutes. I come to a page that needs scrolling, naturally I reach up to the touchpad with 2 fingers... moving it back and forth to get a scroll thinking for a moment damn computer is locked up or slow... only to discover that I was the component with the issue. It didn't help that my daughter was staring at me funny wondering what I was doing. She was still laughing even after I explained myself.

iTouch as a Birthday Gift
So last week was the same daughters birthday. I bought here a new iTouch. She loves it when I let it leave my hands for her to use. The first couple of days were great. She asked me "how do you turn it on?". I said, "It has one button... push it!". She would ask, "How do I get back out of this application?". I would say, "It has one button... push it!". And of course, she quickly gain the necessary skills and probably has surpassed my abilities on the thing within a few days.

PC is Not an iTouch
So last night she was asking me for some sync help between the laptop and iTouch. After a little conversation, she understands what she needs to do... she needs to hit the sync button on the laptop. What does she do? She taps the screen on the laptop... not once, but a couple of times and then begins to laugh. It was funny.

MacBook as a Fish Tank
Last example. I love to scuba and I love the ocean. When I saw the aquarium screen saver for the mac, it was an obvious purchase. So there is a setting on the screen saver, which reads "Enable Motion Sensor Water Tilting". First you have to turn this on! It uses the motion sensor on the mac so that if you tilt the laptop it appears that physics has applied forces on the water in your laptop the way you would expect. The water tilts! Here's the deal: The optical illusion is so good that even really savvy software developers are impressed and want to know: How?

Call to Action: Better Human Interfaces
If you combine the above stories with the fact that I just finished reading "Dreaming in Code", which outlines how far we haven't come in software development for the last half of a century, I'm left restless. There has to be more... there has to be better... Meaning more we can do and better ways of interfacing with computers. We are just beginning to see it. When you look at Microsoft Surface, Apple's iPhone and the promise of RFID, you begin to see it. It isn't what the general software developer is being train on or developing... They are still working on Dialogs.
Those who claim to be on the cutting edge, they are working on web 2.0 with javascript and cool new frameworks (they are cool). But that isn't what the future demands. The future demands seamless integration computer to human... where the human gestures to something and the machine understands. Where the computer knows what is expected and provides recommendation and choice. In this world, the interface isn't always a screen... and the input isn't a keyboard or a mouse!

Speaking at Websphere Portal Techincal Conference

I will be introducing the world of Spring to the world of Portlet development at the IBM WebSphere Portal Technical Conference. The conference is in Nashville, TN between Oct 13-16. The topic of the session is Annotated Portal Development with RAD and Spring; session D19.

Sunday, August 24, 2008

Spring JavaScript

I'm sitting in Keith's Talk @ NFJS Orlando on Spring JavaScript . I've worked with a lot of the spring framework on varies projects over time. I have not until now had a chance to look at what SpringSource was doing with JavaScript. This is great technology which desires some blog time in the future.

There is an underlying theme in the approach Keith is describing which I really like. The concept is a design approach where ajax provides value-add to a client which allows for javascript. Yet the application still functions without it.

Impressions from a one hour guided tour. Things I liked:
  1. Choice of dojo as the underlying framework
  2. Design approach
  3. Use of Tiles
  4. Leveraging of yahoo performance rules for script compression and optimization
Things to look forward to:
  1. Binding of multiple decorations to the same html element
  2. Closer look at Spring's CSS Framework
Great example application was demo to show off spring capabilites... but it is actually a very useful application reporting dependencies of osgi bundles. Take a look:

Thursday, August 21, 2008

Fixing Java Memory Tools on Mac OS X

A number of the Java memory management tools with the default distribution on Mac OS X Leopard are broken. The information to repair the situation seems to be hard to come by. This post will detail the steps necessary to get jmap and jhat to work on a Mac for Java 6. I assume that Java 5 has the same issue but haven't checked.

Setting up a test Java process to profile.
1. From the terminal: cd /Developer/Examples/Java/JFC/Java2D/
2. From the terminal: java -jar Java2D.jar &
3. After the process starts it should indicate the pid (in this example it is 5510)
4. You can also use jps to discover the pid: jps -l (then look for the Java2D.jar)

Fixing jmap
If you type jmap , you would expect to get a high-level memory dump... instead you get a message like:
attach: task_for_pid(5510) failed (5)
Error attaching to process: Error attaching to process, or no such process

To fix this, do a sudo, such as sudo jmap .
Debugger attached successfully.
Server compiler detected.
JVM version is 1.6.0_05-b13-52

using thread-local object allocation.
Mark Sweep Compact GC

Heap Configuration:
MinHeapFreeRatio = 40
MaxHeapFreeRatio = 70
MaxHeapSize = 88080384 (84.0MB)
NewSize = 2686976 (2.5625MB)
MaxNewSize = -65536 (-0.0625MB)
OldSize = 5439488 (5.1875MB)
NewRatio = 2
SurvivorRatio = 6
PermSize = 21757952 (20.75MB)
MaxPermSize = 88080384 (84.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
capacity = 10551296 (10.0625MB)
used = 4592152 (4.379417419433594MB)
free = 5959144 (5.683082580566406MB)
43.52216069002329% used

At this point it looks like it is working, however the file dump doesn't work.

Fixing jhat
When running jhat on the hump dump, you get the following error:
Eliminating duplicate references.....................
Snapshot resolved.
Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
... 3 more

It took me a little hunting to uncover the issue. It turns out that jhat uses the Java 6 js engine. If you go to the terminal again and run: jrunscript , it indicates that the script engine for language js can not be found. On the mac, if you execute: jrunscript -q, which provides a listing of script engines you'll see:
Language AppleScript 2.0.1 implemention "AppleScriptEngine" 1.0
Thank you apple!

As a side note if you actually wanted to run AppleScript as a shell, type jrunscript -l AppleScript

Let's get to fixing the issue
  1. Download JSR-223's engines
  2. Download Rhino
  3. Copy jsr223-engines/javascript/build/js-engine.jar to /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/ext/
  4. Copy rhino1_7R1/js.jar to /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/lib/ext/
** you have to be sudo to do steps 3 and 4.

now jrunscript -q should look like this:
Language EmbeddedECMAScript 1.6 implemention "Mozilla Rhino" 1.6 release 2
Language AppleScript 2.0.1 implemention "AppleScriptEngine" 1.0
Language ECMAScript 1.6 implemention "Mozilla Rhino" 1.6R7

... and jrunscript will put you in a js shell.
... and jhat heap.out now works! Point your browser at http://localhost:7000 and object browse!

Also something I didn't realize until I was preparing for this post... jmap worked for the console dump if I sudo'd the command. However it would not do a file dump. I did the file dump using jconsole and jmx. Now that the scripting issue is fixed, jmap is improved in the following manner:
  1. if you type jmap , it now prompts you for your admin password (instead of just failing)
  2. jmap -dump:live,format=b.file=heap.out 5510 now works

It makes me wonder what else wasn't working! Happy Coding!