Tuesday, May 25, 2004

How much do you use your tools?

To what extent do you use the tools at your disposal? We were involved, for the longest time, in writing a set of productivity tools for developers. We had excellent competition but our experience with our customers and their users was always that people knew very little about their tools and its capabilities.

How much do you know your tools? I have used IntelliJ Idea. Its a brilliant IDE. I have seen other people use it. They suck at it. They could as well use any other text editor with code completion. They have no idea what Idea can do for them (no pun intended).

Monday, May 24, 2004

Gosling, James

I had a chance to meet James Gosling at a meeting with HYSEA which he graciously (albeit in a slightly bored manner) attended and gave us a few minutes of insight into his thoughts on a variety of subjects and primarily on Java.

Some excerpts : (I am writing this from memory so the words arent the same ones he used and I shall try to the best of my knowledge to convey what I understood :-) )

What do you think about releasing a version of Java which embraces the Windows platform, e.g. providing easy access to the Win32 API without having to resort to JNI?
Developers are not feeling a need for such a release. The way Java works is that if a bunch of people need a particular feature say Scanning, then the go out and design a high level API that captures the essence and much more of the requirement which will have the default implementation perhaps only on Windows but the ability to extend it remains. Other examples are the NIO subsystem.

What would you design differently in Java if you got to design it again?
I wanted to make the syntax as close to C or C++ at that time because they were the most commonly used languages. At the end however, syntax is syntax. I would have changes the syntax of the switch statement.

What can we expect in the JDK 1.6 release?
Its too early to say what can be expected in the JDK 1.6 release. However, if you feel strongly about something you should talk to the expert group at the JSR. JDK 1.5.1 will have a release providing features similar to AOP.

What do you think about Java being taught in colleges?
Pascal used to be taught because if you made any mistakes, it was easy to explain them. In C if you go past an array, you find out about it in mysterious ways. Java has an easy to use memory-model and has the same qualities as Pascal. Pascal did not have too many commercial implications. Java has considerably many. Therefore using Java in colleges to teach programming makes a lot of sense.

And some more...maybe later

Tuesday, May 18, 2004

Common Problems

Recently I concluded an engagement which involved reviewing and commenting on someone's Java code. While submitting the results, the discussion turned towards some common problems. Interestingly we are grappling with the same problem at my work place too. How do you do error handling, good exception handling with effective user feedback?

It all drills down to being able to identify the exact cause of the problem and to be able to suggest solutions to it. It so turns our that this seems to be quite difficult to do.

Where does the difficulty lie? I think the difficulty builds over time. e.g.
If I write some code that does a file copy I will end up doing the following

public void copy(InputStream src, OutputStream dest) throws IOException;

What is wrong with this code? A bunch of things and I do not know what to fix in it.
IOException has about 20 different direct sub-classes. Out of which this operation could potentially raise over half of them. Most implementations handle this by simply catching it and if they do not ignore it (god forbid) they just show an IO Error message to the user. If you have a Java aware user, well good for you (my experience with Java aware developers are that they do not understand these exceptions anyway) but for a Java unaware user what do you say?
The only way you can provide effective feedback is to catch every single type of exception and try and figure out what it means. Would you find in yourself the motivation to do that?. You are still left with a bunch of IOExceptions ranging from not enough diskspace to remote file system is not accessible, permission problems etc. You are still constrained by the effective user messages of your library.

How does one solve this problem? Our customer asked us if we knew of any third party exception handling package that he could download. Now thats a killer application.


Check out who all are arguing about it too...
gosling@artima
Hejlsberg@artima

Saturday, May 15, 2004

Easy Software Development?

Joel has an Excellent new article that I agree with very strongly. About how software development is considered to be something anyone can do quite easily. Most people do not realize the complexities of software development. Along the same lines, recruitment processes in most companies are driven by aptitude expecting that a person with a good aptitude (IQ) will be able to code better because its all about logic.
I dont think so.
I think its much more than just logic. Programming well requires a discipline, requires you to enjoy what you are doing, it requires a way of thinking that comes from practise as well as love for programming. Its like saying that spending 4 years in college learning software development is a waste of time. It doesnt teach you everything but it makes you much better than someone who learnt something else.
Joel touches on several other aspects of how software development is complex and involves a lot of variables. An excellent read!

I have come across recent examples of working code which is so terrible that its disgusting. These are examples of high aptitude people who are coding for the amount of time needed by when they can be automatically promoted to a position where they can delegate it to someone. These "managers" will of course continue to fuel jokes in Dilbert.

Friday, May 14, 2004

Interesting Performance Problem : The Usual Suspects?

An interesting performance problem got solved this week. One of our clients noticed dramatically bad performance in our Java servlet/jsp web-server compared to a competitor.

The usual trick to narrow these down are to take thread dumps at the time when the server looks busy. It kept showing us dumps that seemed like most of the time was spent waiting for the database to respond. A quick timing calculation showed that the database was taking a short fraction of the time. After introducing more timing stats between some large pieces of execution we managed to find a bottleneck only to see that it moved the next run - thus making us suspect Garbage Collection. Switch on -verbose:gc and there we were minor Garbage Collection Runs a full 8 and a half seconds.

The Usual Suspects are runaway streams, memory leaks, excessive object creation none of which could be caught in our JVMPI profiler. Amazingly, even after 3 days of intense debugging we knew it was GC that was leading to our problems but we could not isolate what it was that caused it!

We tried IBM JDK and its VM and we compared identical to our competitor. IBM JVM is an amazing piece of software but thats a story for another time.

None of the usual suspects seemed to be involved. We went back to commenting out pieces of the offending JSP and isolated the problem to excessive try-finally blocks in our code generation. We got rid of them and lo behold! we were as fast too!

Why would try-finally result in such high GC times in Sun JVMs? I can only suspect if GC happens when there are a lot of try finally blocks the code is unoptimized? Would love the answer to that one...