SPUG: software libertarianism (was: Scope question)

Tom Legrady legrady at earthlink.net
Mon Jun 17 14:33:40 CDT 2002


If we're playing "what's wrong with Java", I'll take my term as the next contestant. Since I got laid off, and need something to pass my time while waiting for jobs to become 
available, I've been learning Java, to add to my arsenal.

1) Arrays and Collections: You can initialize a collection from another collection, but yoiu can't initialize a collection from an array.

	// good
	//
	Vector myVector = new Vector();
	myVector.add( "string 1" );
	myVector.add( "string 2" );
	ArrayList myArrayList = new ArrayList( myVector );	

	// not good
	//
	String[] myStringArray = new String[] { "string 1", "string2" };
	ArrayList myArrayList = new ArrayList( myStringArray );

While collections are in many ways more convenient than arrays, arrays decorate the type of the objects being stored, while collections conceal it. If I write a method which 
takes a String[], I don't have to worry about someone invoking it with an Integer[], but if my method takes an ArrayList, who knows what type it contains? In certain cases, 
that's good; since every class implements toString, if I simply want to print something, the ArrayList is more polymorphic. But if I want to do something more specific, I need 
specific types.

2) Streams, Readers, Writers, Channels: Being able to obtain varying capabilities by wrapping streams and readers around each other is an interesting idea, but figuring out 
what sequence of IO classes you need to get the desired end result is a challenge. 

This class only reads into a byte[], that one only processes a char[], the other requires a String.

I suppose it isn't so much a language problem as a documentation problem, needing a simple way to know which classes to mix and match for the desired result.

3) Exceptions: Exceptions are wonderful, but their enforcement is pedantic. Since you have to handle exceptions, anyway, it discourages checking conditions. For 
example, you can verify myFile.exists() && myFile.canRead(), but you still have to handle FileNotFoundException. Further, if you have a return statement within a try block, 
java complains  that the method can exit without a return.

Something which REALLY irritates me, but isn't really the fault of Java, but rather of the IDE I use .... When I'm typing in code, Forte helpfully displays a tooltip suggesting 
completions for the methods which are valid at this point. I love that, especially as a beginner, it means I can spend almost as much time in the IDE as I do browsing the API 
for the classes and methods I need. The tooltip mentions exceptions which may be thrown. But as soon as the method has been written down, and I'm ready to write the 
catch line, the tooltip disappears. If I didn't pay enough attention, I have to make the tooltip re-appear, or scan through the API, to determine the correct exception to list.


Overall, I would categorize Java as a low-level language, like C & C++, more suitable for implementing libraries and high-level, application-specific languages. 


Tom Legrady




 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list