Java 8 Launch Q&A
Java 8 is one of the most highly anticipated programming language updates in many years. The release contains a date API, streams API and lambdas. Include permgen removal and you end up with a nice set of improvements. To learn more about this release, we sat down with Georges Saab, vice president of software development, Java Platform Group, Oracle.
InfoQ: For those of us who haven't been following the lambda project too closely can you give us an idea of what was involved in the implementation? I believe this is the first time language, VM and libraries have all been evolved together in such a coordinated way.
Many of the larger features in previous releases were done in a way that only one of these three areas were affected, or alternatively the changes to each area were introduced over the course of a number of major releases.
With Lambda in Java 8, we made a coordinated set of changes across the language, libraries and the JVM, where over the course of its development, each area was able to influence and strengthen the design and implementation of the others.
For example, we experimented with different alternative implementations of Lambda on the VM, and found that we could use InvokeDynamic. In doing so, we found things that could be improved in InvokeDynamic. The desire to use Lambdas in a natural way with collections led to the design of the Streams API, and so to extension methods, which required support in the language.
This has been an evolutionary process over several years with lots of great community feedback along the way.
InfoQ: Do you think the addition of lambdas will bring Groovy and Scala developers back to the Java language?
It is interesting that the two languages you mention (as well as a host of others) run on the JVM. In fact we have done a lot of work to support languages other than Java on the JVM, and think there is a lot for language implementers to learn from experiences of what works well and what doesn't. Of course it is far easier to experiment in a language with a few thousand developers than one with many millions. What we are really focused on is addressing the things that will improve life for the millions of Java developers out there ‐ evolving in a thoughtful and responsible way.
InfoQ: The combination of Lambda and the Streams API's help us develop clear concise code, but concerns have been expressed about potential performance overhead, as filter after filter is applied to narrow down a set in a functional way. Is this a reasonable concern? What optimizations have been introduced to mitigate that overhead?
Streams support intermediate and terminal operations. Intermediate operations like filter do not actually perform any filtering themselves, they instead create a new Stream, which, when traversed, provides the elements of the filtered Stream which match a given predicate. So on one hand, creating additional filters could result in additional work being performed by the runtime.
On the other hand, processing streams lazily, like all intermediate operations on streams do, allows for significant efficiencies, as multiple operations can be fused into a single pass on the data. Together with powerful JVM optimizations under the hood, which the design of lambdas carefully enables, the potential impact of additional filters could be significantly reduced.
Another item to consider is that making use of parallelism becomes much easier with Streams and lambdas. In addition, operations on parallel streams may benefit from relaxing ordering constrains where users do not particularly care about the encounter order of the underlying stream.
InfoQ: Another significant feature of Java 8 is Annotations on Java Types to allow pluggable type checkers to be developed. Can you tell us a bit more about that - for example what kinds of things do you hope to see developers doing with it?
This feature allows annotations on the names of types in most places where those types can be used. As a result of that change, developers can now write annotations to detect error conditions at compile time using pluggable type checkers. Such checkers and annotations schemes are being developed in the community for null pointer errors, locking and internationalization issues.
A great source of information and implementation is Prof. Michael Ernst's Checker Framework from checker-framework.org, which includes a checker for nullness, among more than a dozen such tools. Michael has also served as the co-spec lead on the JSR 308, where this language feature was specified.
It would be nice to see the results of at least one such annotation scheme being applied to the JDK code base in the future, and, of course, to see the broader Java developer community start to use this technology in their own code bases and develop new checkers for other software quality issues.
In particular in respect to embedded and safety critical systems, this kind of innovation could allow crucial properties and constraints on types and their use to be qualified and statically analyzed as part of the compilation process, providing a path for users of other, domain-relevant programming languages to migrate to the Java platform in the future.
InfoQ: What do you think are the biggest enhancements for dynamic languages in Java 8?
InfoQ: Concerns around Java and security have rarely been out of the headlines in the last year. Does Java 8 contain any specific improvements either to the Java browser plug-in or elsewhere?
A number of important security improvements and new features have been delivered as part of Oracle Java SE 7 updates, including Deployment Rule Sets and Exception Site Lists. Maintaining the security worthiness of Java is a top priority for us.
In addition, Java SE 8 contains several new security features. The most immediately visible ones may be the enhancements in the Transport Layer Security implementation: TLS 1.2 is now the platform default. Across the board of security APIs, there are a number of other enhancements, from certificate revocation checking improvements to new cryptographic algorithms.
InfoQ: Do you know the percentage of Java developers using Java 5, 6 and 7? Are there any plans to speed up adoption of Java 8?
Over the last 6-9 months, I have spoken at conferences around the world, and each time I ask folks what version they are using. Based on this informal and unscientific survey, most Java developers are using Java SE 7 today, with a clear (but non negligible) minority still on 6, and a small number on versions older than that. From a developer perspective, Java SE 8 comes with very compelling reasons for fast adoption in the form of new language features and APIs. With IDEs like NetBeans, Eclipse and IntelliJ IDEA working hard to provide great tooling for those features in their upcoming releases, I would expect to see developers embrace it quickly.
InfoQ: One of the big themes for JavaOne last year was around platform unification for Java ME, SE and EE. How far has Java 8 moved us in that direction?
One of the many new features in Java SE 8 is the support for Compact Profiles. They define a few subset Profiles of the Java SE Platform Specification, enabling applications that do not require the full platform to be deployed and run on small devices. Coupled together with other improvements in HotSpot, like the reduction of class metadata footprint, and the VM footprint in general, this feature allows JDK 8 to be scaled down for application development and deployment on small devices. In order to make this easier, a new tool called jdeps is included in JDK 8, which lets developers find out which Profile their code depends on.
Coming from the other direction, Java ME 8 is being enhanced to include closer language, VM and library alignment with Java SE 8. While you won't be able to use lambdas in your Java ME 8 code just yet, the platform now supports Java language constructs introduced in Java SE 1.5, 6 & 7, like assertions, generics, enumerations, strings in switches, try-with-resources statements and the diamond operator. Similarly, the core class libraries have been updated with support for modern web protocols, like IPv6, and advanced security features, including support for TLS 1.2, bringing the Java SE and Java ME platforms much closer together than in the past.
InfoQ: When will we see Stripped Implementations added to Java?
Once Java SE 8 is released, we will need to take another look at how this feature can be added to the Platform in a release prior to Java SE 9. It is not a technical problem, but a matter of ensuring that the specification text and the associated legal framework allow relevant use cases while avoiding fragmentation of the Java platform.
Many thanks to Georges for answering our questions. Oracle will be formally introducing Java via a Webinar later today, and InfoQ will be there to report on it.
I hope revive Security problem and Client side Java application experience
How Can We Use Our Creative Power and Technological Opportunity to Address the Challenges of the 21st Century?
Gyorgyi Galik Feb 26, 2015