Will value types and structured arrays be Java 9's cap feather?

Scalability and performance are always issues that dog the Java platform. But with so many lessons learned from languages like Scala and Clojure, will Java 9 take on these scalability issues by introducing immutable types like structured arrays and value types?

Even as of early 2015, Java 8 is still fresh and new with something intriguing to offer developers. But Java 9 isn't that far off. Both versions are likely to change how the language works in pretty profound ways, with the introduction of immutable types, be it as value types or structured arrays, being on of the most anticipated Java 9 features. With so many other useful and highly functional languages to compete with today, this is how Oracle is pushing keep Java competitive.

Because we've added lambdas on top of generics and the generics weren't really fixed, the code is going to get really difficult to read.

Kirk Pepperdine

Lambdas are a long-awaited upgrade

Gil Tene, CTO and co-founder of Azul Systems, speaks highly about the changes and updates made to the language with the release of Java 8. "Lambda expressions are a really cool new feature. It's probably the most major development-affecting feature in a long time. Really, if you look at the evolution of the platform, there have been plenty of libraries added and standards updated. But as far as the way you code and the way you program in Java, not much has changed since Java 5. In Java 8, you have new syntax and new ways of saying things. It will be something that Java developers adopt more quickly than Java 6 or 7, I think, because of that."

A rush to adopt the new syntax could spell trouble

Of course, the introduction of generics in 2004, the big shift in Java 5, still has some in the development community struggling, even though ten years have have passed. Java performance expert Kirk Pepperdine assumed generics could be used in a sensible way, but he worries that those who are too aggressive with the old feature can cause future issues in their applications. For example, it might be nice to write something like a sorting algorithm once and then put it away and use it for any type. Instead, he's discovered that developers use generics in ways that make code unnecessarily complicated. "I have a framework that some guy wrote for me. He loosened the type system but unfortunately he did it in such a way that the code is so tightly coupled that I can't change one thing without breaking everything else. From my perspective, putting the generics in there made the code more brittle—not more useful."

Pepperdine said he believes the Java community is still suffering from a generics hangover. Things are likely to get even worse with Java 8 lambdas in the mix. "Because we've added lambdas on top of generics and the generics weren't really fixed, the code is going to get really difficult to read." He advised a cautious but determined approach to incorporating lambdas into programming practices.

Complimentary features compete for attention in Java 9

The Java community may be struggling with the previous changes, but there is still a lot of anticipation surrounding the course of innovation for Java 9. Tene mentioned value types, tracked objects, and StructuredArray as worthy candidates for a Java 9 release. Each feature overlaps the other to some degree, while each one also meets a separate need.

"In their pure form, value types are useful for small objects in functional programming semantics. They're most useful feature will be improving the return time for lambda expressions. When you need to return something that's not a current primitive out of the lambda expressions, you end up having to allocate an object. If you could form it as a value which has only some of the features of an object but which is known to be immutable, there are a lot of interesting optimizations that can happen on the functional side."

Value types can also be used in arrays of objects, which brings up Gil Tene's and Martin Thompson's pet github project: StructuredArray. As Tene states in his thorough treatment of the topic here, the StructuredArray approach to ObjectLayout is focused on reducing indirection, improving locality, and making regular striding patterns exposed to hardware (or software) prefetchers. It might capture the benefits of C without necessitating any fundamental change in the Java language. There's no telling if the feature will make it into Java 9, but Tene does think some form of ObjectLayout will be ready for Java 10.

Shocking reliability in release timing satisfies the community

Perhaps the most important milestone from a business perspective was that Java 8 actually launched on schedule. This is the first time in more than seven years that a Java release has been rolled out at the predetermined time, ready to be immediately implemented. This is a big win for vendors in the Java ecosystem and for the clients who rely on them for support in migrating to the latest version. This may be a critical accomplishment for Java 9 and 10 as well. Hopefully, the Oracle team will make timely releases a new trend over the next seven years.

What new features would you like to see in Java 9? Let us know.

Dig Deeper on Core Java APIs and programming techniques

App Architecture
Software Quality
Cloud Computing
Security
SearchAWS
Close