BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Articles JavaOne 2013 Roundup: Java 8 is Revolutionary, Java is back

JavaOne 2013 Roundup: Java 8 is Revolutionary, Java is back

Leia em Português

This item in japanese

Bookmarks

JavaOne 2013 was recently held in San Francisco, from September 22 to September 26. The festivities kicked off Sunday, with a Strategy Keynote by Oracle employees Peter Utzschneider, Nandini Ramani and Cameron Purdy.

It was the 18th JavaOne conference, and the Java community shows no signs of slowing down. Utzschneider told the audience that Java is still the number-one development platform in the world and the number of JUGs has been increasing by 10% year-over-year.

The Future of Java

Ramani discussed the current state of Java and how there are several different SDKs for Java: Java SE 7, CDC 1.1 (based on SE 1.4.2), CLDC (based on SE 1.3) and Java ME, just to name a few. In the past, these implementations served their specific vertical markets very well, but each implementation has diverged and become more and more siloed over the years. With Java 8, there will be a compact profile that replaces CDC.

The APIs between ME and SE will be similar, and the language will support all features in both. Java 8 will bring platform unification: code portability, commonality of APIs, common tooling - from SE embedded to server-side development with Java EE. In the future, there will just be one type of Java developer.

Other cornerstones in platform strategy include: synchronizing releases (Java 8 Early Access is available now) and working with partners (ARM, Freescale, Qualcomm) to make Java a first-class citizen in chipsets. In August, Oracle launched Java Platform Integrator Program to easily port and extend Java Embedded.

Java EE 7 shipped last summer, which is a big milestone considering that it's been talked about at the last two JavaOne conferences. Purdy mentioned three areas have been emphasized in EE 7: developer productivity, meeting enterprise demands and HTML5.

Two years ago, when Java EE 7 was announced, the major theme was cloud. Now EE 7 has many ease-of-use features for cloud deployments, including security enhancements, default resources, schema generation, a client API for RESTful services and JSF skinning for multi-tenant applications. Lastly, Cameron announced Project Avatar is now open source. Avatar is similar to Node.js, but runs on the JVM.

Java 8 Is Revolutionary, Java Is Back

The big talk of the conference was Java 8, exemplified by Mark Reinhold in his Technical Keynote. Java 8 contains many new features, including a new Date and Time API ( JSR 310), Nashorn JavaScript Engine, Type Annotations ( JSR 308), Compact Profiles and Project Lambda (JSR 335).

Lambda is the single largest upgrade to the programming model. Ever. It's larger even than Generics. It's the first time since the beginning of Java that we've done a carefully coordinated co-evolution of the virtual machine, the language and the libraries, all together. Yet the result still feels like Java. -- Mark Reinhold

Brian Goetz, Java Language Architect at Oracle, went on to show how lambdas can remove a lot of the boilerplate just to represent simple ideas. Before lambdas, developers often used a poor "beef to bun ratio" to express ideas, often with inner classes. Goetz showed the following example:

    Collection<Person> people = …;

    Iterator<Person> ip = people.iterator();
    while (ip.hasNext()) {
        Person p = ip.next();
        if (p.getAge() > 18) {
            ip.remove();
        }
    }

To abstract this idea, developers can rewrite the test into a predicate and write it as follows:

    Collections.removeAll(people,
                          new Predicate<Person>() {
                              public boolean test(Person p) {
                                  return p.getAge() > 18;
                              }
                          });

With lambdas, it's much simpler:

    Collections.removeAll(people, p -> p.getAge() > 18);

Not only are lambdas a nicer syntax, they uses invokedynamic to result in more compact bytecode that is more performant. As proof that the language and its APIs have improved, Goetz talked about the new stream API and how you can use it to do bulk operations on collections. For example:

    int highestWeight = people.stream()
    	                      .filter(p -> p.getGender() == MALE)
    	                      .mapToInt(p -> p.getWeight())
    	                      .max();

This provides syntax, performance and abstraction, and you also get parallelism. Java 7 added a new Fork/Join framework for decomposition, but its API still made it hard. With Java 8, you merely have to make a one-line change, changing stream() to parallelStream():

    int highestWeight = people.parallelStream()
    	                      .filter(p -> p.getGender() == MALE)
    	                      .mapToInt(p -> p.getWeight())
    	                      .max();

To learn more about Project Lambda, see http://openjdk.java.net/projects/lambda or download Java 8.

NetBeans 7.4

John Ceccarelli, NetBeans Engineering Director, gave a Chess Game demo of editing an HTML5 application (written in Knockout.js). He demonstrated how it was possible to tweak properties in NetBeans (similar to how you'd do it in Firebug or Chrome Developer Tools) and have those instantly be reflected in your browser without reloading. It looks very similar to IntelliJ IDEA's LiveEdit plugin.

Last year, NetBeans introduced Project Easel, which was designed to add advanced HTML5 support to NetBeans. Ceccarelli mentioned the community's reaction was "Hey, that's great, but we want it in our EE projects." The good news is NetBeans 7.4 RC1 was released right before JavaOne, and it includes support for HTML5, Java EE, Java Web and Maven Web projects.

In addition to live editing of HTML and CSS, NetBeans 7.4 includes JavaScript framework support for Angular, jQuery and Knockout.js. This means the code editor is aware of all your DOM ids, as well as model names in your JavaScript. NetBeans 7.4 is all about mobile web and mobile hybrid (via Cordova 3.0 support). It's interesting how its live edit feature can be used on mobile devices in addition to desktop browsers. The latest release candidate can be downloaded from netbeans.org.

The Chess Server for the aforementioned demo was written using Java EE 7 and deployed on GlassFish 4. The application has five distinct modules: Chess Endpoint, Player Registration, Chess Engine, Chess Game Manager and Persistence Manager.

The Chess Server uses many new Java EE technologies, including: WebSockets, Batch, EJB, JPA, JAX-RS 2.0. All the communication between the client and the server is done via JSON. Santiago Pericas-Geertsen, a member of the GlassFish team, showed some code illustrating how easy it is to setup a WebSocket endpoint with Java EE 7:

    @ServerEndpoint(value = "/chessserver",
                    encoders = MessageEncoder.class,
                    decoders = MessageDecoder.class);
    public class ChessServerEndpoint {

        @Inject private GameCatalog catalog;

        @OnMessage
        public Message onMessage(String message, Session session) {
            return message.processMe(this);
        }
        ...
    }

The client API to talk to this endpoint is pretty similar and looks easy to implement.

The final technical innovation on display in Oracle's Technical Keynote was the DukePad. The DukePad, is a do-it-yourself, make-at-home tablet computer based on the Raspberry Pi and JavaSE 8 Embedded. They found that CPU performance isn't great: the Raspberry Pi CPU is almost as fast as a Pentium II, 14 times slower than a Samsung Galaxy S4 and 94-100 times slower than an Intel Core i7 processor. However, the GPU is pretty good, 400 times faster than the Pentium II had in 1996.

OpenJFX has had most of its components open sourced, including iOS and Android prototypes. The presenters mentioned its forums are healthy and they've received a lot of bug reports from users. They've also received a fair amount of community contributions. JavaFX is included in JavaSE 8.

For Java 9 and beyond, Oracle has a number of initiatives. The main ones are Java on GPUs, Reification (getting rid of erasure in Generics), JNI 2.0, Memory-Efficient Data Structures and building a modular platform with Jigsaw.

The Java Community

The Java Community Keynote was kicked off by Donald Smith, Senior Director of Product Management at Oracle. He brought many different folks on stage to talk about inspiring end user cases of Java technology.

Tori Wieldt, talked about the Raspberry Pi Challenge and how there were 25 developers who participated and seven projects completed. Heart of Glass (monitoring heart rate in real time with Google Glass) and MTAAS (Monster Truck as a Service) were two of the successful projects that emerged from this event. It was also announced that Oracle has signed an OEM agreement with the Raspberry Pi Foundation. They're going to start including Java SE with some of their images, so Java will be included out-of-the-box!

Other notable announcements in the community keynote include: Square has become a member of OpenJDK and Devoxx4Kids is looking for JUG leaders and parents to host workshops in their own cities. Of course, Aditya Gupta's demo of how to be a Minecraft hacker was one of the highlights. It was also one of the first Eclipse demos used in keynote presentations. He made pigs fly and explosions create more explosions, learning most of it with help from his dad, Arun Gupta, and Minecraft Forge.

Oracle Academy got a mention from Alison Derbenwick Miller. It offers curriculums for K-12 students, as well as universities. It educated 2.5 million students last year and offers student workshops, teacher development and discounts on certifications.

Following the education portion of the community keynote, many robot demos were on display. James Gosling even made a guest appearance to talk about the work he's doing.

Proof That Java Is Back

The strategy and technical keynotes were instrumental in explaining why Java is back. Java 8 hopes make it fun to program in Java again (by reducing boilerplate code) and there are lots of APIs in Java EE 7 that should make it easy to build modern applications. There's further proof in some recent articles:

If you didn't get a chance to attend JavaOne this year, you might want to add it to your calendar for next year. If not for the technical content, do it for the networking. The Oracle Appreciate Event was off the hook with free food, beer and music from Maroon 5 and the Black Keys. The parties are back, and the exhibition hall was overflowing.

More than anything, the enthusiasm of the developer community seems to be as strong as ever.

About the Author

Matt Raible has been building web applications for most of his adult life. He started tinkering with the web before Netscape 1.0 was even released. For over 15 years, Matt has helped companies adopt open source technologies (Spring, Hibernate, Apache, Struts, Grails, Bootstrap, jQuery) and use them effectively. Matt authored Spring Live and Pro JSP. He is also the founder of AppFuse, a project which allows you to get started quickly with Java frameworks, as well as a committer on the Apache Roller and Apache Struts projects.He knows and Loves: HTML5, CSS, JavaScript, CoffeeScript, jQuery, AngularJS, Java, Spring, Scala, Play! Framework, Groovy, Grails, Tomcat, Jetty and PhoneGap.

Rate this Article

Adoption
Style

BT