“Can we make it easy to write clear, error free code?” Oracle’s Java Language Architect Brian Goetz asks in his talk Java Language and Platform Futures: A Sneak Peek at Devoxx Belgium 2016.
There are a few interesting features coming into the future of Java, with no promises on when or which versions. They include expanding type inference to include local variables, reducing boiler plate code, and looking at amending the switch statement to evaluate expressions instead of statements. The bigger projects are Project Valhalla and Project Panama.
This aims to “reboot the layout of data in memory” in order to reduce the amount of memory used fetching objects from memory compared to, for example, arithmetic calculations. Not all classes need mutability or polymorphism. To do this, the project explores value types, generic specialisation and enhanced volatiles, and more.
Value types would provide JVM infrastructure to work with immutable, reference-free objects. This will be essential when high performance is required, and pairs of numbers need to be returned. Using primitives avoids allocation, but an object to wrap around the pair gives the benefit of abstraction. This project looks to open the door to user-defined abstract data types that perform like primitives.
Project Panama attempts to utilise the wealth of native libraries available and make it easier for Java developers to work with, for example, C libraries. It will do this by improving and enriching the connections between the JVM and non-Java libraries. This is discussed in the interview below, and in the Devoxx BE keynote.
How to prioritise?
The main principle behind developing the future of Java is to evolve the language slowly: “first, do no harm”. It also is to take the long term view in increasing developer productivity and code clarity.
We caught up with Brian Goetz at Devoxx Belgium to get some insights into how the Java Language Architects go about deciding which features to work on, and Project Panama.