The State of Java
I think living in a beautiful city in a fantastic climate has its advantages. Not just the obvious ones, but we find people unusually keen to come and visit us on the pretence of presenting at the Sevilla Java User Group (and please, DO come and present at our JUG, we love visitors).
This week we were really lucky, we had Georges Saab and Aurelio Garcia-Ribeyro giving us an update on where Java is now and where it looks like it’s going in the future.
I’m just starting to use Java 8 in real life, so this could not have been better timed - I got to ask the guys a bunch of questions about the intentions behind some of the Java 8 features, and the current vision for the future.
My notes from the session:
- Lambdas could be just a syntax change, but they could be more than that - they could impact the language, the libraries and the JVM. They could have a positive impact on performance, and this work can continue to go on through small updates to Java that don’t impact the syntax.
- Streams are a pipeline of operations, made possible/easier/more readable by lambdas. The aim is to make operations on collections easier and more readable.
- In the Old World Order, you had to care about how to perform certain operations. With streams, you don’t need to tell the computer exactly how it’s done, you can simply say what operations you want performed. This makes it easier for developers
- Streams will take all the operations you pass in and perform them in a single pass of the data, so you don’t have to write multiple loops to perform multiple operations on the same data structure, or tie your brain in knots figuring out how to do it in one loop. There are also no intermediate data structures when you use streams.
- The implementation can be optimised under the covers (e.g. not performing the
sort
operation if the data is already ordered correctly), and the developer doesn’t have to worry about it. Java can introduce further optimisations in later releases without changing the API or impacting the code a developer has already written. - These new features in Java have a focus on readability, since code is much more often read than written.
- The operations are easier to parallelise, because the developer is no longer dictating the how - multiple
for
loops might not be easy to parallelise, but a series of operations can be. - Default methods and new support for static methods on interfaces are interesting. I’d forgotten you could put static methods on interfaces and I’m going to sneak them into my latest project.
- Nashorn is here to replace Rhino. Personally I haven’t worked in the sort of environment that would need server-side JavaScript so this whole area has passed me by somewhat, but seems it might be interesting for Node.js or creating a REPL in JavaScript that you want to run on the JVM.
- The additional annotation support in Java 8 will be useful for Java EE. As this is something I’m currently playing with (specifically web sockets) I’m interested in this, but it seems like it will be a while before this filters into the Java EE that’s used on a daily basis.
- Mission Control and Flight Recorder - look interesting. Feel like I should play with them. - Many people are skipping straight from Java 6 to 8 - the new language features and improved performance are major driving factors
- End of public updates of Java 7 in April. Having libraries that, um… encourage… adoption of the latest version of Java makes life a lot easier for those who develop the Java language, as they can concentrate on moving the language forward and not be tied down supporting old versions.
- Either this is the first time I’ve heard of JavaDB, or my memory has completely discarded it. I had no idea what it was.
- Java 9 is well under way, check out the JEPs.
- (This is the JEP process)
- Jigsaw was explained, and actually I could see myself using it for the project I’m working on right now. I had a look to see if I could use it via the OpenJDK, but it looks like the groundwork is there, but not the actual modules themselves.
- The G1 Garbage Collector is “…the go forward GC”, it’s the one that’s being actively worked on.
- This is the first I’ve heard of Enhanced Volatiles, I’m so behind the times!
- Access to internal packages is going away in Java 9. So don’t use any
sun.*
packages. Use jdeps to identify any dependencies in your code that need to change. - …and, looking further ahead than Java 9, we have value types and Project Valhalla
- …a REPL for Java
- …possibly a lightweight JSON API
- …and VarHandles were also mentioned.
- Finally, the guys mentioned a talk by Brian Goetz called “Stewardship: the Sobering Parts”, which has gone onto my to-watch list.
Ideas
It became clear throughout the talk there are plenty of ideas that we could explore in later presentations. If you want to see any of the following, add a comment or ping me or IsraKaos on twitter or Meetup and we’ll try and schedule it.
Similarly, if you can present on any of these topics and want to come to a beautiful, sunny city with amazing food to do so, drop me a line:
- The OpenJDK
- The JCP, the purpose, the processes, the people
- Adopt a JSR, Adopt OpenJDK
- New Date/Time (JSR310)
- JavaFX
- Code optimisation vs Data optimisation (I honestly don’t know what this means, but I wrote it down in my notes)
- Java EE
Further Reading
- I really liked Richard Warburton’s Lambdas and Streams book
- Java 8 in Action has details on other Java 8 features like Date and Time
- Java 8 for the Really Impatient covers JavaFX too, and highlights some Java 7 features you might like
- Brian Goetz did a great talk last year, “Lambdas in Java: A peek under the hood”. I had to watch it twice before even half of the info sank in, but it’s really interesting.
- Stephen Colebourne, the guy behind Joda time and the new Date and Time API, has this talk about the new API.
- Java 9 OpenJDK page