Monday September 11, 2006 The past few weeks have been pretty entertaining: there's the final crunch to getting JDK6 out the door (with the side-thrill of coordinating with the tea-leaf-reading exercise that is Windows Vista), bringing closure to the open source debate, and the most fun: figuring out the plan for JDK7. This last is the geek version of writing up a Christmas Present wish list.
The list is mostly being put together by Danny Coward and Mark Reinhold, with a lot of kibbitzing from a cast of thousands. We do surveys of partners, fold in statistics from the bug voting system, stir up with our own opinions and then run the JCP debate.
There's an entertaining little firestorm going on over closures. Neal Gafter, Gilad Bracha, Peter Ahé and many more are fighting it out. The really heated debate is all in email and I'm incredibly far behind in reading it (by several hundred messages).
I have somewhat mixed feelings about closures: they are pretty complicated. But they're an instance of what I think of as the Black Hole Theory of Design. I have a really strong memory from years ago of Guy Steele saying roughly "Lisp is a Black Hole: if you try to design something that's not Lisp, but like Lisp, you'll find that the gravitational forces on the design will suck it into the Black Hole, and it will become Lisp". [Guy doesn't actually remember making this remark, but he does say it sounds like the kind of flip comment he would make; I could also be totally mis-remembering who said it, but I haven't found any quote like it through Google].
Closures feel to me like one of these design Black Holes. When inner classes were
designed, we wanted to avoid the complexity of closures. But this brought about
oddness and tension of it's own that has left me less than happy with inner classes.
So, should we just give in to the force of gravity and go the rest of the way?
The debate's afoot. It's going to be an entertaining year.
Permalink
Comments [39]
TYPO : "There's an entertaining little firestorm going on over clusures" -- you mean "closures" ?
I look forward to Dolphin(JDK 7) feature list callout.
Meanwhile, does anyone know why logging to the XMLFormatter's log records do not include the chain of exceptions(cause and its cause) ? (whereas if I target logs to the SimpleFormatter, all the Exception's causes print themselves in the hierarchy).
BR,
~A
Posted by anjan bacchu on September 12, 2006 at 12:22 AM PDT #
How much more complex does the compiler/language get and how many times is the addition useful enough to justify that increase in complexity?
Personally speaking, I think Java has been moving down the line towards gaining esoterica for the sake of some corner cases or adopted language level constructs where API additions would be sufficient for 80 percent of cases.
That is not something I ever wanted for Java especially as we started out with the mantra about taking all the cruft out (unlike C++) and having a nice explicit language with no dark corners (auto-boxing anyone?).
I'd certainly like to hear your views on the tensions in inner classes. I'd also be interested in hearing about what you intended inner classes to be used for and comparing that with how they are used by the masses.
Posted by Dan Creswell on September 12, 2006 at 01:25 AM PDT #
I like inner classes compared to closures because I find inheritance of multiple methods and fields better and because it is one concept, the class. In summary:
I have suggested an RFE that shortens the syntax:
The reason for suggesting the shorter syntax is that this seems to be a large driver in the proposals for closure and alike.
Posted by Howard Lovatt on September 12, 2006 at 01:37 AM PDT #
Posted by Julian Morrison on September 12, 2006 at 03:20 AM PDT #
Closure = Poor Man's Inner Class
How can this be when inner classes have a subset of the functionality of closures?
Posted by Alex on September 12, 2006 at 03:35 AM PDT #
Actually that should should be:
Inner Class = Poor Man's Closure
I don't really think the Java community understands closures. I really hope closures are going to make it in the language. I really hope generics will get fixed.
Guys ... do something right for a change. Lets fix those oddities that make Java complex.
Posted by Alex Nedelcu on September 12, 2006 at 03:57 AM PDT #
Posted by Dim on September 12, 2006 at 04:16 AM PDT #
Posted by Ivan on September 12, 2006 at 04:44 AM PDT #
Posted by Mike Atkinson on September 12, 2006 at 05:35 AM PDT #
Posted by Mike Atkinson on September 12, 2006 at 05:36 AM PDT #
Posted by Fuerte on September 12, 2006 at 05:53 AM PDT #
I'm slowly deciding that I'm against closures. The main argument for closures I've seen is that closures let us create something like anonymous inner classes more efficiently. I use anonymous inner classes as markers for prototype code that needs refactoring; eventually the anonymous inner classes get to grow up to be first-class critters. If anonymous inner classes are the larval stage of named classes, I'd treat closures as an egg stage. I don't think I need it.
My other concern is that closures may never get refactored into named classes. That'll lead to the same non-evolutionary path that Smalltalk/ObjectiveC categories led to. Categories are fine while the original development team is around, but a year or two after they're gone the dead code crushed the live code.
Posted by David Walend on September 12, 2006 at 06:14 AM PDT #
Posted by javaniraj on September 12, 2006 at 06:24 AM PDT #
Posted by Chris Reigrut on September 12, 2006 at 07:52 AM PDT #
Posted by Sam on September 12, 2006 at 08:14 AM PDT #
Posted by warren henning on September 12, 2006 at 08:24 AM PDT #
Posted by Fuerte on September 12, 2006 at 08:36 AM PDT #
Posted by Julian Morrison on September 12, 2006 at 08:39 AM PDT #
Posted by Antonio on September 12, 2006 at 09:13 AM PDT #
Posted by Byron on September 12, 2006 at 09:54 AM PDT #
I thought that from day 1, Java didn't allow multiple superclasses because of the inherent complexity? We can argue until we're blue in the face about how interfaces are only a partial solution, and how allowing multiple superclasses would really make Java a more productive language. It's really the same thing with closures- yes, they could potentially improve the language IF they were done right (and that's a big if), but it wouldn't be java anymore. Just understanding closures requires a different way of thinking about programming than most java programmers do right now. Would java programmers be benefited by expanding their minds and learning these ideas? Yes, definitely. Should java programmers' minds be expanded by expanding the java language? No, definitely not. The paradigms of closure-oriented programming are just too different. Heck, if aspects can't be in the same language and need to go into AspectJ, then closures definitely shouldn't be in there.
It's too late for java to start introducing radically different ideas like closures. Java has (I think) done a lot for improving language design on the whole; it's time to pass the torch to the next language that will get it right the first time.
In the meantime, making things more natural (by getting rid of primitives) instead of less natural (by hacking closures, because I can't imagine closures not being a hack this late in the game) would be a good step.
Posted by Liam on September 12, 2006 at 10:09 AM PDT #
Posted by Vagif Verdi on September 12, 2006 at 10:18 AM PDT #
Posted by Christian Schlichtherle on September 12, 2006 at 10:20 AM PDT #
Posted by Doug Erickson on September 12, 2006 at 11:11 AM PDT #
Posted by Jeff Read on September 12, 2006 at 12:46 PM PDT #
Inner classes add quite a lot of runtime overhead, enlarge programs, ... - could'nt this been done in an easier way?
Posted by Linuxhippy on September 12, 2006 at 02:43 PM PDT #
I should explain my:
Glib comment. I see the advantages of inner classes as:
On the down side I see:
But if you look at the advantages of closures, these are alsmost seperate issues and are not really dependent on closures and could be added to inner classes without introducing a new concept. I.E.:
(That is assuming that their is broad agreement that these really are problems with inner classes. I suspect many people are quite happy with how inner classes are right now.)
Posted by Howard Lovatt on September 12, 2006 at 05:17 PM PDT #
This is an interesting discussion, but there's one problem: the debate is largely subjective, full of opinions and short on data. Do you remember the formatting/indenting/brace wars? Who won that debate?
It's hard to objectively measure if closures are better or not. IMHO, Java (and predecessors) rose to prominence because they solved important, objective problems. Specifically, Java addressed reliability and robustness concerns while delivering excellent runtime performance. That's something everyone can agree is a good thing.
I am all for open debate, but I wonder if our time is better spent solving bigger problems. Maybe we should identify those problems first before trying to solve them.
Posted by Madhu Siddalingaiah on September 12, 2006 at 06:54 PM PDT #
If not then, can the two languages still interact?
I'd like it to be easier for the JVM to work with other languages seamlessly -- including (or perhaps especially) ones that support closures.
I'd like to have the portability of running in a JVM as well as the wealth Java libraries available to me with more language choices.
Posted by Bill Robertson on September 12, 2006 at 07:00 PM PDT #
Posted by Anonymous on September 12, 2006 at 09:24 PM PDT #
Posted by Ivan on September 12, 2006 at 09:55 PM PDT #
Posted by Jose M. Arranz on September 13, 2006 at 01:07 AM PDT #
Posted by Mike on September 13, 2006 at 02:52 AM PDT #
Posted by Sam Griffith Jr on September 13, 2006 at 04:59 AM PDT #
Posted by Peter Parker on September 13, 2006 at 10:30 AM PDT #
You could just add better dynamic-language support to the JVM, and let other languages like Groovy and JRuby handle cases where you want those powerful language features.
That way it wouldn't clutter up Java. I agree closures are a great thing. But you could keep the Java syntax simple and when people want that power, jump to another language that still boils down to the same thing on the JVM. Java's simplicity _is_ a good thing.
If you want to change Java, I agree- fix primitives. And possibly Properties vs. getters/setters.
Posted by Tom on September 13, 2006 at 11:50 AM PDT #
For those that would like immutables to be added to Java you can vote here:
Posted by Howard Lovatt on September 13, 2006 at 09:20 PM PDT #
Posted by lb on September 14, 2006 at 04:06 PM PDT #
Posted by Bernd Eckenfels on September 14, 2006 at 09:38 PM PDT #