JAX London 2012 was last week (2012-10-15 to 2012-10-17) but I haven't had time to sit down and think about what to write till today for lots of reasons, none of which are interesting to anyone other than me.
The first of these, It's All About Processes Communicating, was really an introduction to dataflow approaches to solving problems and to ![GPars project
logo.](Images/gpars_64x64.png)GPars as a framework for supporting them using Java and ![Groovy
project logo.](Images/groovy_logo.png)Groovy codes. The first part of the talk was a bit of a rant against application level us of the operating system technique of shared mutable memory multi- threading - this is where the squirrels played their part. Squirrels are very territorial and despite there being five bird feeding stations to choose from the senior squirrel refuses to let any other squirrel eat from them. Squirrels therefore deny parallelism. This led to a short discussion of the synchronized keyword in Java and the fact that any and all locks are designed to stop parallelism. So in today's world if you need more performance, you need to use parallelism, so you need to avoid locks.
The session then moved onto a short description of actor model, dataflow model, and Communicating Sequential Processes (CSP). Although I had been intending to present examples of dataflow model and data parallelism, both of which are well supported in GPars, I took the decision to focus on actor model, which is also well supported in GPars. So I skipped the material about approximating the value of Pi, and moved straight to the Sleeping Barber problem. This led to showing various examples of Java and Groovy code using GPars to create a simulation of the problem. This isn't really about performance increase it is about avoiding deadlock. I think the examples worked well. They and many other are in a Git repository. To clone use http://www.russel.org.uk/Git/SleepingBarber.git to just browse go via http://www.russel.org.uk/gitweb.
The second talk the following day, Closures: The Next "Big Thing" in Java, was proposed before I knew Brian Goetz was giving the opening keynote. Since he covered much of what IO was going to cover I did a serious overnight rewrite of my talk to try and be a reprise and follow on from what he had talked of.
The session started with a concern over whether people would follow the changes in Java or whether they would just stick with the version they know: many people are still using Java 1.4.2. Personally I find this shocking: they consider the changes of Java 5 to be to big a change for no benefit, and Java 6 and 7 with them. Of course Java 8 will be an even bigger change. The session then moved onto a short description of the lambda expression syntax, trying to ease people towards it using examples from Scala and Groovy.
Of course the lambda expression syntax is really just a bit of syntactic sugar in many ways, but the introduction of defender methods and the massive changes in the way data structure libraries are used is the real message of Java 8. Stopping using "external iteration" and starting to use "internal iteration" is the big shift: a move to a more functional viewpoint. Actually also a move to a more object-oriented viewpoint. Too many people are writing Java code in C idioms of iteration.
The shift brings massive pay off when wanting to harness parallelism. You can get it for free. At least data parallelism, the sort of parallelism associated with the use of sequences. The squirrels made an impromptu appearance here to deny the need for parallelism a bit more.
The session closed by showing GPars and Scala examples of what Java 8 will bring. Java 8 is in the future, Scala and GPars are here now. Indeed GPars can be used to do Java 8 style programming using Java 6 and Java 7. So the push was to get out there and use GPars to change you programming style now the new Java style.
Of course the squirrels had to make a reappearance. Hopefully people found the sessions enlightening and informative.