Subscribe

Share

Interview

Innovate with Java 8

Latest platform release enhances developer productivity and supports applications from the Internet of Things to the cloud.

By Caroline Kvitka

May/June 2014

The latest release of the Java platform, Java 8, is a significant upgrade, undertaking a coordinated coevolution of the virtual machine (VM), core language, and libraries. Caroline Kvitka sat down with Nandini Ramani, vice president, Java Platform and Internet of Things, at Oracle, to find out what’s new in Java 8, which encompasses Java Platform, Standard Edition 8 (Java SE 8) and Java Platform, Micro Edition 8 (Java ME 8). The following is an excerpt from that interview; listen to the full interview at oracle.com/magcasts.

Oracle Magazine: In a recent Java Magazine article, Chief Java Architect Mark Reinhold called Java 8 “revolutionary.” What are the top features that make it such a game changer for Java developers?

Ramani: Java SE 8 is a big step forward in modernizing the Java language as well as modernizing the Java libraries. It’s the biggest upgrade ever to the Java programming model, and it includes several new features, including lambda expressions and default methods; a new date and time API; Nashorn, the JavaScript engine; and compact profiles.

Oracle Magazine: What are lambda expressions, also known as closures, and why have they gotten so much attention?

 
While lambdas enable developers to simplify the code they write every day, the key benefit comes in when they are combined with new aggregate operations on collection APIs that have also been introduced in Java SE 8.

Ramani: Good programming is about finding the right abstractions, and Java has always been very good at helping us abstract over data. But one area where we saw we could improve was in abstracting over behavior, such as allowing developers to effectively say “do this for every matching element of this collection, and then do that when you’re done.” Lambdas are that missing tool for describing these snippets of behavior, and being able not just to pass around data from one method to another, but also to pass around behavior. This was possible to some degree with anonymous interclasses, but it was just too unwieldy and required too much boilerplate code. While lambdas enable developers to simplify the code they write every day, the key benefit comes in when they are combined with new aggregate operations on collection APIs that have also been introduced in Java SE 8. This is really important—it’s the combination of language and libraries that makes lambdas such a huge step forward.

Let’s take an example. The new stream libraries in java.util illustrate how it is now possible to take a more functional approach to code in Java, which can make code more compact and less error-prone, by allowing the programmer to focus on the “what” of the problem being solved without getting bogged down in the details of “how.” One way this approach pays off is that we can now write code that need not be inherently serial or parallel, but can switch from sequential to parallel execution without having to rewrite the whole thing. If the user asks for a parallel execution, the library takes care of partitioning, task decomposition, and thread scheduling, leaving the user free to focus on the “what” of the problem they are solving. And this is just one of the many benefits enabled by this style of programming.

Oracle Magazine: Do users have to switch to new libraries in order to benefit from these abilities?

Ramani: No, because this illustrates the benefit of the other key new language feature of Java SE 8, called default methods, which is a mechanism that allows existing libraries to evolve to gain new functionality over time, without breaking backward compatibility. We added these features to the collection libraries Java developers already use every day.

Oracle Magazine: So do lambdas change the way developers do their day-to-day jobs?

Ramani: Absolutely, and hopefully at multiple levels. At the simplest level, their code can be more compact, but when combined with the libraries like the stream library I described above, developers will be able to write code that is simpler and more maintainable—as well as gaining the benefit of easier parallelism. I wish I had this back when I used to program!

 
We’re unifying the language, the platform, and APIs as well as modernizing the Java language and libraries.

Oracle Magazine: What is significant about the new date and time API?

Ramani: The new date and time API reduces the complexity for developers when handling date and time, especially when having to cope with internationalization and localization for different markets. While Java has always had an API for dates and times, the existing library is more than 15 years old; it was time to re-engineer it from the ground up using modern design practices.

Oracle Magazine: What about Nashorn?

Ramani: Project Nashorn is a rewrite from scratch of the JavaScript engine included with the Java platform. When developers want to use both Java and JavaScript, Nashorn can deliver significant performance improvements and interoperability between Java and JavaScript code.

Oracle Magazine: Java SE and Java ME are heading toward a convergence. Can you give us a little background on that and tell us what steps Java 8 takes toward it?

Ramani: Java ME is the Java platform standard for resource-constrained and connected devices where the full Java SE may not be a good fit. It allows Java to address a wide range of smaller embedded devices and use cases.

We’re converging the language, the tooling, the libraries, and the APIs. The alignment between Java ME and Java SE creates a unified Java development model and allows code, skills, and tools to be portable across the Java platform all the way from small to very large systems. The large Java ecosystem of more than 9 million developers and partners can now easily scale any of their innovations.

Java ME 8 is a significant update of the Java ME standard and is a major step toward alignment of Java SE and Java ME. Java ME now supports most of the modern Java SE 8 language features such as generics, annotations, assertions, enumerations, and multicatch. Java ME 8 also supports recent Java SE VM features and class file versions, allowing the use of common tooling.

Finally, Java ME 8 adds key Java SE APIs and libraries such as collections, events, StringBuilder, logging, and other APIs and interfaces as well as subsets of NIO [New I/O].

Oracle Magazine: How do the compact profiles, which you mentioned earlier, fit into the convergence?

Ramani: Compact profiles are a way for developers to use a well-defined subset of the Java class libraries for applications where that is all that is required. So, if you’re just writing a small application, you don’t need to include the entire JRE [Java runtime environment]. For situations where the size of the JRE is an issue, this will address those specific needs.

Oracle Magazine: Speaking of writing small applications, let’s talk about the Internet of Things [IoT]. What does Java ME offer for developers who want to build IoT devices?

Ramani: The Internet of Things brings huge opportunities, but along with it, significant challenges for software development and specifically deployment. How do you develop code efficiently for a wide and fragmented set of embedded platforms? How do you ensure robust and secure software execution under particularly challenging conditions in most cases?

 

Typically, embedded software development involves specialized skills and platform-specific tools as well as, in most cases, low-level native programming. Because the native programming approach to embedded software development is often very fragmented, Java ME 8 is a purpose-built embedded software standard that provides a consistent and reliable application platform that shields developers from the complexity of the underlying devices. Complexities of operating systems, device drivers, and so on are abstracted away, making software development for embedded systems much easier. The Java ME 8 runtime is efficient and highly scalable and allows developers to move and reuse their applications and business logic across a wide range of embedded solutions without having to recompile or port their applications. So in the real world this means you can start with small microcontroller-type devices and go all the way to more-powerful systems like gateways and concentrators.

Java ME 8 includes rich and standardized functionality that is becoming increasingly required in advanced embedded deployments such as preintegrated software provisioning and management, a flexible and robust security model, and standard communication protocols.

Oracle Magazine: What are you most excited about in terms of Java 8? Ramani: We’re unifying the language, the platform, and APIs as well as modernizing the Java language and libraries, so it’s a big upgrade for the Java programming model itself. Additionally, we are keen to make it simple for developers to write and deploy applications all the way from small devices to the data center. Java SE 8 and Java ME 8 are huge milestone releases toward that goal.

Next Steps

DOWNLOAD
 Java SE 8
 Java ME 8

 WATCH the Java 8 launch webcast

 READ the Java 8 issue of Java Magazine

 

Photography by  Lui Peng, Unsplash