Skip to main content

The Terror That Is Autoboxing

Posted by javaerb on September 11, 2003 at 10:25 AM PDT

Don't I have anything good to say about anything? Well, yes I do. I have learned to love Python. Which means I should not be a stickler for strong typing, and therefore autoboxing should be right up my alley.

Let me tell you about something that always drives me crazy. I read articles about how to optimize Java code. One warning often heard is that creating a lot of objects has a high overhead. I believe that is true; in fact it has been true for a long time, all the way back to the dawn of C++. I also believe that if you can't create tons of objects in an object-oriented language, why bother?

Well, HotSpot and faster computers may have minimized the risk of object creation. I don't know what the experts currently say about this. But if I get sloppy in my coding, and keep interchanging, say, ints and Integers, resulting in objects being created under the covers all over the place, with my compiler not catching it, isn't that a problem? Wouldn't I be just as well off using Python?

Again, as I have said or could say about many of the new language features: When you try to make a language all things to all people, you end up with... C++? C#?, no, it looks like... Java.

Related Topics >>