Skip to main content

Feels Just Like It Should

Posted by editor on August 19, 2008 at 7:12 AM PDT

Shouldn't closures be about expressiveness?

In another sign that the debate over closures remains robust and unresolved, Tapestry creator Howard Lewis Ship has added his thoughts to the discussion. In the blog entry My Ideas for Java Closures, he says he currently gets a lot done with inner classes, but "it really comes down to conciseness. I can accomplish pretty much everything I need using inner classes and holder objects, such as AtomicInteger and friends. But it ends up being more code than I'd like."

So what does he want from a closure syntax? He starts with the basic principle of what is to be accomplished in the first place:

What I want (to borrow Stu's term) is to emphasize the essence of my logic, and strip away the ceremony: the naming of the interface (it should be known from context), the types of parameters (just the names, please), the list of thrown exceptions, etc.

Howard wants closures defined in terms of an interface that contains a single method, with the closure block granted read/write access to local variables and method parameters (an ability to be provided by syntactic sugar). The closures would be exposed via a Groovy-like syntax:

I think Groovy has the right syntax here. The important part is for the compiler to actually help out rather than for it to complain from the side-lines. Today's Java compiler has all the type information, but just uses that to build fancy error messages about what you should have typed. It should be using that type information to avoid the necessity of all the extra typing (that is, keyboard entry, not the need for types in the Ruby/Groovy sense of the word).

Ultimately, Howard sees CICE as the current closure proposal closest to what he wants, though he thinks the specifics of the proposal bog down on details that the compiler should be able to resolve.

My basic concept is: Less is More. Support fewer cases but do so more cleanly, more concisely, and more understandably. Simplify. Let the compiler do more work. Reduce the density and complexity of the Java code. Expose the essence.

So there you have it, another voice added to the closures debate, one which calls for clarity and expressiveness (as opposed to "everyone will hate Java if it doesn't add Ruby-like features, and soon"). But is this the right approach, or will it get hung up on edge cases or other gotchas?

Also in Java Today, The Aquarium reports on a Java EE 6 milestone in JAX-RS in Proposed Final Draft... and Jersey also Supports Spring. "JAX-RS (REST Support for the Java Platform aka JSR-311) became the first Java EE 6 specification that Reached Proposed Final Draft stage - download the PFD Specification and please provide feedback. The team work now is on the TCK and the RI (see JCP Process). Jersey is both a Reference Implementation and Production Quality and will continue to evolve and add useful features, like the Integration with Spring."

Shai Almog has posted a New LWUIT Eye Candy Video. "The LWUIT team just posted this new video to YouTube showing off some of the latest features in LWUIT together with some tried and true features. Check out the drag & drop functionality and "swing-in/swing-up" dialogs and menus."

Today's Weblogs begin with a blog from Terrence Barr Comparing LWUIT and JavaFX Mobile. "Open sourcing LWUIT last week has created a lot of buzz - the response has been phenomenally positive. We've also gotten a few questions regarding the relationship of LWUIT and the upcoming JavaFX Mobile platform - there still seems to be a bit of confusion here. So I thought it would be useful to devote a "FAQ" blog entry to this topic."

Tim Boudreau revives some potentially controversial thoughts written a while back in
Nobody Thinks They're An Enterprise. "I wrote this blog nearly two years ago, and was politely asked/advised not to publish it. If I rewrote it today, I'd probably make it a bit shorter. But I think the points are ones our industry needs to learn."

Bruno Ghisi says he's Falling In Love With My Sentilla Perk Kit. "I got a Sentilla Perk Kit. This is my first introductory post showing how to set up the environment and create a simple Hello World."

Today's Forums begin with kaplanj's announcement Wonderland 0.4 released! "See the announcement here: Get the build here: For those of you interested in the source, the tag is "rel-0_4_0" in both cvs and subversion."

JXTA developer keesp has a Migration 2.4.1 to 2.5.0 question. "In the older versions of JXTA, the idea was that you discovered/created a peer group in which you published a module class advertisement and module spec advertisement which provided information about the actual connection. In my code, I used this to make a JxtaSocket. My code was based on "JXTA in a Nutshell" and an older book "JXTA: Java P2P Programming", both based on JXTA 2.4.x. In 2.5.0 (especially reading the programming guide) I get the feeling that discovering/creating peergroups is no longer a best practice. Instead, you discover/create modele spec advertisements immediately and work with these. Reading some forums, I got the idea that peergroups are created automagically 'under the hood' and do not need to be specifically discovered or created."

Finally, osbald asks about
Inputting intervals via JXDatePicker? "Wondering if JXDatePicker can be used to pick a range of dates instead of just one? Certainly JXMonthView is happy when picking ranges. The possible edge case I've been working on is a start & end JXDatePicker pair, the interesting twist comes from them both sharing the same DateSelectionModel and having that model set to SINGLE_INTERVAL_SELECTION. This almost worked except the end date appears as the start date, which I've traced down to a getMonthView().getSelectionDate() in the BasicDatePickerUI."

Current and upcoming Java

Registered users can submit event listings for the href=""> Events Page using our href="">events submission form.
All submissions go through an editorial review before being posted to the

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 it will be
archived along with other past issues in the href=""> Archive.

Shouldn't closures be about expressiveness?