BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

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

Posted by Matt Raible on Oct 20, 2013 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Lambdas by Ilya Palopezhentsev

Lambdas are good but .net had had them in 2007. Also, why does one need methods like mapToInt()? In .net, Select() will deduce return type itself.

lambda by Markus Peröbner

shouldn't it be "Collections.removeAll(people, p -> p.getAge() > 18);" instead of "Collections.removeAll(people, p > p.getAge() > 18);"?

Re: lambda by Matt Raible

Good eye Markus! This typo has been fixed.

Trimmed down .net circa 2008 by Adam Rackis

It looks like Java is releasing a trimmed down set of the features that were released with .NET 3.5 back in 2007. Lambdas are neat, but kind of hoaky without extensions methods. Ie, just imagine if instead of

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

it was

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

Re: Trimmed down .net circa 2008 by Nils Kilden-Pedersen

Thankfully you can use Scala for that.

Re: Lambdas by Robert Sullivan

Does seem a bit awkward, but here's the reasoning behind it from Brian Goetz:
mail.openjdk.java.net/pipermail/lambda-libs-spe...

Java -Lambada by sejal pachchigar

Giving shorter syntax is fine, but this gives rise to lot of run time exceptions like null pointer exception. Users should be aware of such facts.

Re: Trimmed down .net circa 2008 by William H

I actually prefer the Java way of doing this - making the type switch explicit is just easier to read in my option. And given the amount of time and effort that went into consulting Java devs on the approach I suspect most Java devs will also prefer it.

In general Java tends to favour readability over terseness where there is a tension between the two, and I think that's why I tend to prefer it as a language to C# even though they are to all intents and purposes the same language.

Each to their own though - Scala uses the C# like syntax if you prefer this.

Java 8 is Revolutionary? by Faisal Waris

I think the correct title should be "Java Finally Catches up (to where the world was 3 years ago)"

There is still no Async equivalent (even anything announced) which others have had for a while: C# 1 year; F# 3 years; Scala now

Re: Java 8 is Revolutionary? by Cameron Purdy

Faisal -

_Someone_ has to do it first. And to be clear, lambdas date back to the 1970s, not to C# ;-)

Peace,

Cameron Purdy | Oracle

Raspberry Pi Challenge:Seven projects completed or six ? by 马 德奎

in the video ( medianetwork.oracle.com/video/player/2698223954... 03:16),I see there are six projects completed .

Re: Java 8 is Revolutionary? by jeremiah johnson

Faisal -

_Someone_ has to do it first. And to be clear, lambdas date back to the 1970s, not to C# ;-)

Peace,

Cameron Purdy | Oracle


Exactly. What the hell took you so long? Lambdas are INSANELY useful.

Re: Java 8 is Revolutionary? by Rogerio Liesenfeld

Actually, my experience in real-world C#.NET projects says otherwise. Even though the latest version of C# is available, .NET developers keep using regular "for" loops most of the time. They avoid lambdas, except when writing LINQ expressions. And even then, LINQ is mostly underused; more complex expressions are avoided in favor of creating stored procedures/functions in T-SQL. (And, no, I am not talking about some small company developing trivial apps - this is in large codebases developed by dozens of programmers in long term projects.)

This leads me to believe that the same will happen in Java 8-based projects. Most developers, most of the time, will stick to the old idioms and rarely use lambdas, regardless of their actual usefulness. Personally, given the choice I use them whenever possible, but that's just me...

Re: Java 8 is Revolutionary? by Faisal Waris

I agree that the actual use of lambdas will be limited in Java. Lambdas will be mostly used for mapping, filtering, aggregating collections or writing event handlers.

For most current programmers, 'OO-ness' is ingrained and its hard to unwind that.

I think its better to just adopt languages like F# or Scala that offer OO but are first-class functional languages as well. These will force the needed mindset change.

There are trending programming models such as Async, Actor and Reactive that are and will become increasingly relevant and which are very reliant on lambdas and other functional programming idioms such as monads. Java will require major language surgery to support these concepts well. F# already has all of them and so does Scala, I believe. Note that functional languages are much easier to extend and hence offer a better base for new features that will be required in future. Note also that C# has already undergone major changes in the language spec to support LINQ, lambdas and now Async.

I welcome lambdas in Java but calling it 'revolutionary' is a bit much.

Code question by Peter Schaeffer

The code in the article uses Collections.removeAll with a predicate. Where is that method defined? I can't find it in Java SE 6/7/8. Any suggestions? A URL would be great.

What’s not in Java8 by Snehal Masne

On a side note, although date/time handling will be improved in Java8, amazingly there is still no good way to handle currency in Java (something I have blogged about in the past). Doubles (and all floating point numbers) are inherently unsuitable for money, or anywhere exact calculations are required. Using int or long requires keeping track of decimal points, and BigDecimal isn’t ideal either.Those guys may improve things, but it looks like we will have to wait until Java 9 for that :-)

Regards,
www.techproceed.com

Re: What’s not in Java8 by Matt Raible

Does the addition of addition of LongAdder and DoubleAdder change your opinion?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

17 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT