More Thoughts on Tiger



Email    print   
July 1, 2004 —  (Page 1 of 2)
A month or so ago I talked about my disappointment in some of the features of Sun's Tiger (J2SE 1.5) release ("Missed Opportunities," May 1). This month I want to talk about a couple more problems that I see in the new version.

As before, bear in mind that there's a lot of good stuff in Java 1.5. It seems appropriate to devote column space to the features that might give you grief, however, since you're less likely to hear about it from the official documentation.

STATIC IMPORTSLet's start with static imports. Given this code:

package com.holub.test;

public class Constants

{ public static final String HELLO = "hello";

public static String global = " goodbye ";

public static String noNoNo()

{ return "NoNoNo!";

}

}

you can do this:

import static com.holub.test.Constants.*;

public class Foo

{ //...

public static void main(String[] args)

{ System.out.println( HELLO + global + noNoNo() );

}

}

There's no class-name prefix in front of the HELLO or global references or the call to noNoNO();

Importing a global constant like HELLO is relatively (though not completely) harmless. (The problem is that the static final reference might point to an object that can change state. A static final is not a constant. The lack of a true constant in Java has been a problem from day one.)

Nonetheless, I might be happy with static imports if they were restricted to static final fields. Unfortunately, they aren't. You can also use static import to access what amounts to global variables and functions. I've deliberately used the word "function" rather than "method" in the last sentence. The function noNoNO() is not really a method of a class of objects-it is not called to handle a message passed to some object; noNoNO() is a procedural function, pure and simple.

Yes, Virginia, you can now write a C program in Java. (In fact, if you're really a hard-core C programmer, they've added System.out.printf(), which works just like the C function with the same name.) The language is just too complex to justify its use in non-OO applications. Introducing global variables and global functions is a giant step backward.




Pages 1 2 


Share this link: http://sdt.bz/27969
 
Most Read Latest News Blog Resources

Add comment


Name*
Email*  
Country     


  • Comment
Loading




close
NEXT ARTICLE
DBMoto 5 Hits More Databases, More Securely
Sometimes it’s hard to know where data has been. That’s why DBMoto 5, the latest database replication and synchronization engine Read More...
 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 

Download Current Issue
FEBRUARY 2012 PDF ISSUE

Need Back Issues?
DOWNLOAD HERE

Want to subscribe?


 
blogs tab
Are you at risk for burnout?
Burnout is a severe problem and it can strike at any time. Here's how to tell if you are nearing the edge.
02/09/2012 02:16 PM EST

Agility, mom, and apple pie
If we're to evaluate the state-of-the-art in software development, we should start with the values espoused in the Agile Manifesto.
02/07/2012 11:57 AM EST

RIM woos developers with free tablet
How do you get more apps ported to the BlackBerry PlayBook? By giving every developer a free tablet, of course!
02/04/2012 01:57 PM EST

GitHire: Use Headhunters to Find Your Perfect Programmer
Are you a hiring manager tired of scouring the job boards? Check out this new service that will find 5 people interested in your jobs.
02/03/2012 12:17 PM EST

Facebook claims hacker cred
Facebook's SEC S-1 filing form includes a short essay on the Hacker Way by Mark Zuckerberg himself.
02/02/2012 08:26 AM EST

Ryan Dahl steps down
Ryan Dahl, creator of Node.js, steps back from his position as gatekeeper for the project.
02/01/2012 04:58 PM EST

 
Events calendar tab
2/13/2012 to 2/16/2012
Santa Clara
TechWeb

2/26/2012 to 2/29/2012
San Francisco
BZ Media

2/27/2012 to 3/2/2012
San Francisco
RSA

3/4/2012 to 3/7/2012
Las Vegas
IBM Tivoli

3/5/2012 to 3/9/2012
San Francisco
TechWeb