Wednesday, April 27, 2011

All I Want for Java 8 is...

With Java 7 considered practically a done deal (I've had it installed on my home computers as the primary JRE for weeks now), many of us are starting to dream about what might come with Java 8. In this post I briefly look at what I'd like to see in Java 8 before looking at some other folks' wish lists for Java 8. I'll end this post with my ideas on what it most likely to go into Java 8.

My Java 8 Wishlist

Full Runtime Generics Support

I think the thing I would most like to see in a future version of Java (and the sooner the better) is reified generics. Although there are many minor syntactic sugar changes that would be nice, the erasure of generics type erasure would be most welcome.

JMX 2.0 Features

In the first response comment to Julian Exenberger's DZone-syndicated version of Java 8.0 Wishlist, Jonathan Fisher states that he'd like, among other things, "Annotation based JMX." I was disappointed when it was announced in the summer of 2009 that JMX 2.0 would be deferred until Java 8. Unfortunately, the relevant Java Specification Request (JSR 255) is in the Inactive state. There are numerous proposed features of JMX 2.0 that I'd like to see. Like Fisher, I'd appreciate annotation-based JMX. Other nice JMX 2.0 features included improved querying and the associated support for JMX web services.

Improved Date/Time Support

In the beginning, there was Date. This class had more than its share of problems and now 2/3 of its constructors (four out of six) are deprecated and nearly all of its methods are deprecated (the exceptions being largely methods overriding Object or implementing the Cloneable and Comparable interfaces).

The Calendar interface and its primary implementation class (GregorianCalendar) were attempts to address the problems associated with Date (though there are arguments for situations when Date is preferable to Calendar).

Unfortunately, Calendar has issues of its own and is not particularly pleasing to use because it sacrifices usability in the name of generality and flexibility (a benefit which is seldom applied because most of us use GregorianCalendar anyway). Many Java developers have found the Joda Time library to be a refreshing approach to handling dates and times in Java.

Many of us were excited at the prospect of Java 7 delivering an improved date/time approach via JSR 310 ("Date and Time API"). Sadly, JSR 310 was not included in Java 7, but it sounds like there's the possibility that it could be part of Java 8. The reference implementation of JSR 310 is the ThreeTen project. It is summarized with this text: "ThreeTen provides a modern date and time library for Java and is the reference implementation for JSR 310. It includes many of the lessons of the Joda-Time project and aims to standardise date and time concepts in computing." I'd love to see JSR 310 implemented in Java 8.

Others' Java 8 Desires

The previously mentioned post Java 8.0 Wishlist outlines some of Julian Exenberger's most desired features for Java 8. These include properties, operator overloading, "finish autoboxing" (methods on literals), and "[making] JavaFX useful." Some of the people commenting on this post vehemently don't want properties or operator overloading. Other people stated their own desired features in comment on this post. These included annotations for checking preconditions and postconditions, modularization, "complete JavaFX," JRE on more platforms, and cleaned up SDK/libraries.

My guess is that one of the most sought-after features for Java 8 is "closures." Indeed, one of the best ways to identify which features are most likely to be most desired for Java 8 is to see what is "most missed" from the proposed but dropped Java 7 additions. I blogged that features such as closures, properties, reified generics, beans binding, operator overloading, and BigDecimal syntax that were dropped from Java 7. The poll on these features had almost half the respondents state that closures was their most-missed feature dropped from Java SE 7.

Charles Nutter would like to see Java 8 add coroutines and he has initiated that effort.

What's Likely to Make Java 8?

We will hopefully have a better idea of what will be in Java 8 by JavaOne 2011. However, we have some information that provides hints as to what we're most likely to see in Java 8. First, Mark Reinhold's famous Plan B gives us a good idea of initial tentative ideas for Java 8: modularity, "Lambda expressions (informally, 'closures')," Java types annotations, and more small language enhancements ("Project Coin 2").

Another good source of what is likely to really be in Java 8 is the article Looking Ahead to Java SE 7 and 8: A Discussion with Oracle’s Java Language Architect, Brian Goetz. In this article, Goetz talks about tentative Java 8 features such as "upgrades to the core Java libraries to more easily express parallel calculations on collections" and "virtual extension methods" (allows adding of " methods to interfaces that specify a reference to a default implementation").


Java is one of the most used programming languages in the world and the sheer size of its developer base means that there will be a wide disparity of opinions on which features Java would most benefit from. However, I believe that dynamic languages on the JVM (such as Groovy) have influenced many of us to favor closures and that is one feature that sounds destined for Java 8.


Martijn Verburg said...

Hi again!

Here's my take on what I think will make it into Java 8. This is based off various informal conversations I've had with Oracle and other OpenJDK hackers.

reified generics

Unlikely to happen, this will be really hard to back port into the existing JVM, not to mention the work required for javac, HotSpot etc.

JMX 2.0 Features

People will need to immediately help out with getting JSR 255 back on track in order to make this happen. I can only suggest that you post on their mailing list and try to fire it up again!

I'm personally hoping to work with the JCP on how they can improve the levels of activity and excitement around JSRs. This is a longer term project however.

Date and Time

The problem here is that the API is large. To have a fully functioning and tested TCK for it may prove to be it's downfall in terms of making it for Java 8.

I think that would be a real tragedy and I encourage as many readers of this blog as possible to get involved in the 'threeten' project as much as they can.

The rest

I think that 'closures' and modularisation will make it come hell or highwater. These are two very important projects for Oracle.


Dustin said...


Thanks again for the insightful feedback.

I agree that it is extremely unlikely that we'll see reified generics in Java 8 because of the backwards compatible concerns that led to erasure in the first place. To be honest, I had resigned myself to never having reified generics until Mark Reinhold opened the door to slight hope for them sometime after Java 8 at JavaOne.

I agree with your assessment that we'll see closures and modularization in Java 8 no matter what because of the tremendous coverage they have received from those working on Java 8 and because it looks like they need these features for language development as much as we'd like them for our own development.


Dustin said...

The post Small java changes which should be in Java 7 talks about changes the blog's author wanted to see in Java 7. Because many of these did not make Java 7, they are the types of recommendations that make sense as a set of developer-desired Java 8 changes.

Javin Paul said...

JMX2.0 is really a cool idea, I have seen power of JMX using MX4j and JMX is getting increasingly popular because of ability to control runtime behavior of program without any down time, though My wish is that Java remains open source, Oracle is not big fan of giving anything free in my opinion.

Top 10 tips on logging in Java

Martijn Verburg said...

@Javin Paul - Java will remain open source, Oracle has stated that clearly on many, many occasions