Wednesday, 17 November 2010

A talk with Brian Goetz on the future of Java

Two days ago, at a one-day mini-conference in The Netherlands, I had the great honor of speaking with Brian Goetz. He talked about the future of Java, Project Coin, Concurrency, Fork-Join and Lambda-Expressions and I asked him about the Oracle takeover, Java on mobile and why Oracle is getting so much bad press lately. Here's an abstract of this very interesting day!

I must start by emphasizing that the entire contents of this blogpost is my interpretation of everything Brian Goetz has said and may not be what was literally expressed by Brian Goetz.

For those of you that don't know, Brian Goetz is a Senior Java Language Architect at Oracle, working on the development of the Java language and platform. This development hasn't had much progress in recent years, because of Sun almost going out of business, but now that Oracle has taken over Sun, there seems to be much more perspective for the development of Java, with a clearly laid-out roadmap and well-specified plans.

To start with, as many of you probably already know, the next version of Java will be split among 2 releases, Java 7 and Java 8. Java 7 will incorporate many things that are "already done for the most part" and Java 8 will have the "bigger things that need more time". The roadmap is now as follows:

Java 7:

  • InvokeDynamic
  • Project Coin
  • Upgrade to ClassLoader Architecture
  • Method to close a URLClassLoader
  • Concurrency & Collections updates (including Fork-Join)
  • Unicode 6.0
  • Locale Enhancements
  • NIO 2
  • TLS 1.2
  • ECC
  • DBC 4.1
  • Translucent & Shaped Windows
  • Heavyweight / Lightweight Component Mixing
  • Swing: Nimbus & JLayer
  • Update to the XML-Stack (JAXP, JAXB & JAX-WS)
Java 8:

  • Modularization of the JVM
  • Project Lambda
  • Annotations on Java types
  • Project Coin part 2
  • Swing JDatePicker
Because of this split-up, Java 7 can now be released somewhere mid-2011, whereas Java 8 will be released somewhere in 2012.

One important thing is missing from these lists: Java on mobile. I asked Brian why it is still so difficult to develop for smartphones. They're all different, there is no single unified platform and it is not that easy to start a Java Applet (such as a JavaFX application) on a smartphone. Ideally, you don't want a distinction between Java SE and Java ME, they should be one platform and it should be just as easy to start a Java Application on a smartphone as it is on a desktop (i.e. Java Web Start). Brian responded by saying that despite the advancements in technology, the cheapest phones don't really get any faster, so it is difficult to create a unified Java platform for both desktop and mobile. Also, Oracle doesn't have any concrete plans yet, so what he could tell me was that "they are working on it". This is not as negative as it sounds though. Brian explained to me that the way Oracle communicates with the rest of the world is actually quite different from how Sun used to do it: Sun was very fast with promises about anything and mostly they were promises they couldn't keep. With Oracle on the other hand, you can count on them to deliver on their word. That also means that they can't say anything about stuff that hasn't been officially put on the roadmap. They have many very large clients, who base their decisions on what Oracle says in the media, so they really have to be careful about that.

Update: Brian sent me an email, explaining that mobile stuff is on an entirely different roadmap. This is the Java SE roadmap, whereas mobile stuff is on the Java ME roadmap. This does mean, however, that Oracle, at least for now, is not planning to merge the two, because in that case, there would be only one roadmap. I think this is a shame, firstly because Sun used to say that the two platforms were indeed going to merge (but maybe this was one of the "false promises" after all) and secondly because I think that unification of the platforms is very important, now that mobile and desktop are moving more and more towards each other. If nothing happens in this area, the "write once, run everywhere"-paradigm, is in serious danger. So let's hope that Oracle is planning some progress here, even though they are not talking about it publicly. End of update.

Brian was also joking about where in movies, you sometimes see people with a little angel on one shoulder and a little devil on the other. At Oracle, he said, you have a little angel on one shoulder and a little lawyer on the other...

But kidding aside, Brian told me that he was very impressed with the quality of management at Oracle. He thought that they are very smart people, who really know how to run a company. And really, there isn't as big a difference between cultures as you might think. They actually get along really well and for the first time in years, Brian actually has a budget to hire people again.

I also asked Brian about the bad press that Oracle has been getting lately. He explained that this also has to do with the fact that Oracle doesn't just say things in the media. They think about it really well before issuing a press release. That is why, in a lot of cases (such as the Apple JVM deprecation), only one side of the story is told in the media, with Oracle not responding to it. People start assuming the worst and when you combine that with the commercial reputation of Oracle, it is very easy to get bad press. Brian assured me, however, that Oracle is really committed to maintaining Java, because Oracle doesn't think about making money in the short term, but really focuses on the future and what is better for Oracle than Java being the number one programming language in the world? For the first time in years, there's really some progress going on.

During the day, Brian gave some very interesting presentations about Concurrency, The Fork-Join Framework and, the most interesting one, Project Lambda. This last one will be absolutely brilliant. Lambda expressions will be "translated" to SAM-types. A SAM-type is a "Single Abstract Method"-type, being an interface with a single method or an abstract class with a single abstract method. A Lamda expression will then have the same type as this SAM-type. Therefore, Lamda expressions can be used in any place where SAM-types are used today, for example ActionListener, Comparable, Cloneable, etc., making them instantly compatible with a large part of the existing API. I'm not going into this very far now, because it will take too much time and I will never be able to explain it as good as Brian can, but I can't withhold from you this piece of code:
//Old-style code:
Collections.sort(people, new Comparator() {
 public int compare(Person x, Person y) {
  return x.getLastName().compareTo(y.getLastName());
 }
});

//Lamda expressions & SAM-conversion:
Collections.sort(people, #{ Person x, Person y -> x.getLastName().compareTo(y.getLastName()) });

//Better Libraries:
Collections.sortBy(people, #{ Person p -> p.getLastName() });

//Type Inference:
Collections.sortBy(people, #{ p -> p.getLastName() });

//Method References:
Collections.sortBy(people, #Person.getLastName);

//Extension Methods:
people.sortBy(#Person.getLastName);
So, as you can see, besides just Lambda expressions, there will be many other optimizations that will allow programmers to optimally take advantage of Lambda expressions. Lambda expressions will also make it easier to write code that is optimized to run on multi-core computers. This is an area where the Fork-Join framework will also provide huge improvements. I've seen some details and the implementation is really smart.

When I told Brian that I thought that the SAM-conversion idea was really brilliant, he politely gave the credits to Joshua Bloch, who apparently came up with the name, and Neil Gafter, for the idea...

Finally, I asked Brian about Java on Apple mobile devices such as the iPhone and the iPad. His answer was both mysterious as well as hopeful. He said that Larry and Steve are really good friends...

So there you have it. One day with Brian Goetz and I have to tell you: at first, when I heard about the Oracle takeover, I was terrified, just as everyone else. The big bad giant that only cared about money was going to destroy Java. But gradually, as the Oracle roadmaps started to trickle out, I became more positive. Still cautious, but more open minded. Then, after reading many articles about JavaOne, I was starting to think that the takeover could actually be beneficial for Java. And now, after this day, I'm positive about that. It is going to be beneficial for Java. I finally had the chance of talking to someone who really knows what's going on and I'd like to tell all of you that I now have full confidence that Oracle is going to keep Java the greatest platform in the software-world!

No comments:

Post a Comment