 |
Broken Hearts Are For...
Posted by invalidname on October 19, 2005 at 11:30 AM | Comments (4)
Buyer's remorse for Generics and Autoboxing?
We knew Generics were coming. There was an implementation of it that could be used with Java 1.4, during the long wait for the J2SE 5 betas and ultimately its final version. So, really, just now people are starting to say that it was a bad idea?
What happened? Did the silent majority get this one wrong? I remember five years ago when it was the most popular item on the bug parade, I didn't really think much of it. I thought that if there really is a critical problem in getting untyped objects from Collections, that to be completely honest, I was far more likely to just do an instanceof on stuff I pulled from the Collection, or to just catch the ClassCastException and live with it, rather than learning a completely new syntax to avoid the problem. 99 times out of 100, my code was the only one populating the Collection, so the chances of getting an unexpected type of object out of the Collection was zero.
So I voted all my bug votes for Java Media Framework stuff that never got looked at. That and the un-deprecation of ServletRequest.getParameter()... bonus points for anyone who sees how that relates to generics, but I digress.
Anyways, maybe there were people with principled objections to Generics, but it seems more people just shrugged and said "yeah, whatever" and plugged away with our work. Generics arrived and suddenly everyone realizes that they're probably more trouble than they're worth. Bruce Tate, in Beyond Java, even sees them as typical of what he believes are Java pathologies:
Java 5 is strongly touted as perhaps the most innovative major release of Java in half a decade. I do agree that it's going to have a significant impact. I'm not at all convinced that all of the impact will be positive. I regularly attend a conference called NoFluffJustStuff. The experts at the conference sit on a panel and answer questions. One of my favorite questions deals with new features in the language. The whole panel agrees that generics, as implemented, are a bad idea. That usually shocks the audience.
If you think about it, the Java generics Java Specification Request (JSR) introduces a whole lot of syntax to solve a marginal problem with no corresponding change to the Java virtual machine (JVM). I'm guessing that the typical Java developer rarely gets a class cast exception. And there are plenty of opportunities. Most of the objects in a typical Java application are usually in collections anyway. Whenever you take them out of the collection, you've got to cast them from Object anyway. At that point, type safety gives you about as much protection as a lap belt in a burning, plummeting 747. Yet, the generics syntax is invasive, and the implementation is worse. In an age when more and more experts assert that dynamic typing leads to simpler applications and productive programmers, Java developers are learning how to build stronger enforcement for static types.
I'm bringing this up because it's come up in multiple discussions in the forums. The thread Comparison operators by value kicks off with ideas about how to resolve some problems with = and == introduced by autoboxing. The thread moves on to consider whether Autoboxing as a whole is a mistake, and then brings in Generics as a fellow poster child for well-meaning features gone wrong. User kcpeppe writes:
No matter the conservative approach (which is the correct one for production) is to not change unless there is a compelling reason and the change will do no harm. I'm sorry but from where I stand, Generics do not meet that bar and autoboxing falls way below it. To be fair, I've seen cases where they can help but these are really use a few edge cases. I don't think the main core language should be designed by exception. n'uff said on this subject!
'nuff said? Do you think features like autoboxing and Generics are misguided? Has Java gone off the rails? Please join in the forum discussions and let us know what you think.
Also in today's Forums, rickcarson speaks up for the advantages of Java's openness as part of the feature discussion in
Re: Need help with research for graduate class:
"I think that if features do not work as documented they should not be included. This was one of the nice things about Java in the early days, and part of the reason why I jumped ship away from the M$FT offerings. In VB or the win32api if something doesn't work as advertised you have two choices: either the frustration of fiddling with it till it works (hello blue screen! hope you saved recently!), or giving up and telling the client it can't be done. A classic example was the ASP Dictionary object, which spat back random garbage, even with only a couple of items in it. Whereas with Java you can look under the hood to see what is happening."
Hans Muller has surprising news in today's Weblogs. In
Official: Swing is the Dominant GUI Toolkit, he writes:
"The most recent Evans Data Corporation developer survey had this to about Swing: 'Java Swing with 47% use, has surpassed WinForms as the dominant GUI development toolkit'. We are number one!"
Daniel Brookshier has
An interview with Brian Koontz, creator of the Open Source Technology program at North Lake College:
"Open Source for college credit? Yes, it's true! Daniel interviews Brian Koontz, Computer Science program coordinator and OSS zealot at North Lake College. Brian created a certificate program for Open Source Technology at North Lake College in Texas. Daniel Brookshier interviews Brian about the certificate and the open source impact of open source."
Finally, Chet Haase lightens things up with some Swing humor in Two Items Walk into a ToolBar...
In Also in
Java Today,
Bruce Tate and Justin Gehtland are back with updated content from
Spring: A Developer's Notebook. In What Is Spring, Part 2, they show
how to use Spring's Web MVC framework to build a web GUI for a simple bike
shop example. This article is excerpted from the updated, current version
of the book, which corrects errors from the earliest printings.
Robin Miller goes against some currently popular thinking in the NewsForge article Three reasons why Internet-based applications are a bad idea: "We've all heard the hype about how Sun and Google may someday, somehow, produce a version of StarOffice or OpenOffice.org that you'll access online through your browser instead of installing an office suite on your hard drive. Even though I think 'The Network is the Computer' makes a fine marketing slogan, I am still going to keep most of my software where it belongs: on my own computer. Here are three reasons why."
In Projects and
Communities,
the Robotics Community's Terminology project hopes to clear up misused and overloaded terminology in the field of robotics by collecting terms and historical data, defining terms accurately, and presenting recommended modern-day usage. The results of the project will be made available under a Creative Commons license
The JAX-WSA project hosts the reference implementation for JSR 261, Java APIs for XML Web Services Addressing, which defines APIs and a framework to support transport-neutral addressing of Web services. The project hosts the early draft of the spec, javadocs, and a weekly build of the reference implementation.
In today's java.net
News Headlines :
Registered users can submit news items for the java.net News Page using our
news submission
form. All submissions go through an editorial review before being
posted to the site. You can also subscribe to thejava.net News RSS
feed.
Current and upcoming Java
Events :
- October 16-20, 2005 - OOPSLA 2005
- October 19-20, 2005 - 9th Jini Community Meeting
- October 21-23, 2005 - Greater Atlanta Software Symposium
-
October 25, 2005 - Detroit JUG Presentation: Object-Oriented Design: From Principles to Patterns
- October 28-30, 2005 - Northern Virginia Software Symposium
- November 1-4, 2005 - Enterprise Java Architecture Workshop: San Francisco
- November 4-6, 2005 - Lone Star Software Symposium 2005: Dallas Edition
-
November 8-10, 2005 - JavaOne Tokyo 2005
-
November 11-13, 2005 - Rocky Mountain Software Symposium 2005: Fall Edition
- December 7-10, 2005 - The Spring Experience 2005
-
December 10-11, 2005 - Weekend With Experts
- December 10-14, 2005 - ApacheCon 2005
- December 12-16, 2005 - JavaPolis 2005
Registered users can submit event listings for the java.net Events Page using our events submission form.
All submissions go through an editorial review before being posted to the
site.
Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the java.net Archive.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
I've used both dynamic typing and static typing languages such as Perl, Python and Ruby. I have to admit that sometimes I do work faster not having to deal with it.
However, I still prefer static typing because I think other people would have to read what I wrote. Or worse, I would have to read what I wrote a year from now. Imagine having to figure out, "okay... what the heck does this collection contain again?"
Yes an expert panel may say that dynamically typed languages may make them more productive. I would be more concerned with the non-expert developers who have to figure out why they are getting ClassCastExceptions so deep in the code. It would've saved them a lot of time to find the error during compile time.
Posted by: atrajano on October 19, 2005 at 10:26 PM
-
The most important thing about generics is their ability to document the contents of the collection. It is so much easier to understand code with generics because it is obvious what is in the Map, or List, or whatever. I can also include parameters that document exactly what the collection should contain... it doesn't rely on me keeping the JavaDoc up to date. Is this of enormous value? Well, it's certainly not the most important thing in the language. But it is helpful.
Posted by: sandtiger on October 19, 2005 at 11:19 PM
-
There is no doubt that Generics and auto-boxing are good language features to have. However the timing of their introduction i.e. JAVA 5 seems to have resulted in their lack of use, atleast from my experience. We have several applications that we support and enhance. These have been built over the last 2-3 years. Frankly speaking, since we are writing our own code, typing it back to what we are expecting is not a big deal. Additionally, most of the experienced programmers that we have do not want to get into a new world of syntax i.e. generics. We are also not comfortable with spending time to rehash some of our code to use Generics. I cannot justify this effort to be back at square one again. I dont see the effort being worth it when we have proper coding standardards and good understanding of what we have written so far.
I am speaking from my practical experience and currently do not want to disturb the ship. So Generics and Autoboxing can wait for all I care.
Posted by: rirani on October 20, 2005 at 01:19 AM
-
Do you think features like autoboxing and Generics are misguided? Has Java gone off the rails? Please join in the forum discussions and let us know what you think.
Did't you just said that there are a lot of forums and expert roudtables where you can here the arguments about the mistake generics are? You want a poll, hoping that hordes of developers will dismiss what experts are saying?
Wake up ! Some of those experts don't care anymore about the future of java as a language. I understand that better alternatives exists.
As for myself I never used generics and autoboxing. I don't develop with Java 5. I use Java 5 only as a runtime environment for obvious reasons. (performance, gc improvement, etc).
Regards,
Horia Muntean
Posted by: sevenm on October 21, 2005 at 08:38 AM
|