JSR 335: Project Lambda JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel

download JSR 335: Project Lambda JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel

If you can't read please download the document

  • date post

    29-May-2020
  • Category

    Documents

  • view

    3
  • download

    0

Embed Size (px)

Transcript of JSR 335: Project Lambda JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel

  • JSR 335: Project Lambda François Sarradin -- Xebia

    λ

  • JSR 337

    Java Roadmap Java 8

    aug. 2013 Java 7

    jul. 2011 Java 9 ?

    ● FP / Parallel comp. ● Date API improv. ● Type annotation ● Compact profiles ● Nashorn

    Modularity Performance Productivity

  • Project Lambda What's in it?

    Project Lambda

    JSR335

    Collection API Bulk Operations

    Lambda Expression Virtual Extension Method

    Collection API Parallel CollectionsFunctional API

  • Question

    What will be the impact of Project Lambda on the Java world?

  • Answer Look at Speed Car!

  • Planning... Presentation + live coding (free to interrupt)

    ● Genesis

    ● Lambda of Java

    ● Project Lambda

  • ...And Then ● Debate

    ● Retrospective (agile style!)

    ● Report ○ Xebia blog ○ Project Lambda ML

  • Genesis

  • More Processors

  • More Expressiveness More Readability

    结果 汉字 = new 物().処理();

    vs.

    fact n = product [1..n]

    Is it all Chinese to you?

  • FP & Competition

    Guava

    Clojure

    C# / F# C++

  • (Anonymous) Inner Class A λ Solution

    Iterables.filter(persons, new Predicate() {

    @Override public boolean apply(Person person) {

    return person.getAge() >= 18; }

    }); // Java + Guava

  • This is what you really need!

    Iterables.filter(persons, IS_ADULT);

    Predicate IS_ADULT = new Predicate() {

    @Override public boolean apply(Person person) {

    return person.getAge() >= 18; }

    });

    (Anonymous) Inner Class A (better?) λ Solution

  • (Anonymous) Inner Class (Not Really) A λ Solution

    Average length of Java one-liner is 21 line! @DEVOPS_BORAT - 12/09/2011

    ● "The pain of anonymous inner classes makes us roll our eyes in the back of our heads every day." (a wise Oracle's client, 01/2011)

  • What about Oracle?

    ● "It’s time to add closures to Java" (Mark Reinhold, 12/2009)

    ● "Oracle's position is that Java must evolve -- carefully, of course -- in order to remain competitive." (Brian Goetz - 08/2011)

  • Lambda of Java

  • Here is the λ!

    (int x, int y) -> x + y

    (x, y) -> x + y

    (int x, int y) -> { return x + y; }

    (x, y) -> { return x + y; }

  • Other λ forms

    m -> { m.put("France", "Paris"); m.put("UK", "London"); m.put("USA", "Washington");

    }

    x -> 2 * x

    () -> 42

  • Inner Class vs. λ Solution Iterables.filter(persons, new Predicate() {

    @Override public boolean apply(Person p) {

    return p.getAge() >= 18; }

    }); // Java 5-7 + Guava

    Iterables.filter(persons, // Java 8 + Guava p -> p.getAge() >= 18);

  • Method Reference

    String::valueOf // like: v -> String.valueOf(v)

    Integer::compare // like: (i1, i2) -> Integer.compare(i1, i2)

    Arrays.sort(myInts, Integer::compare)

  • Virtual Extension Method (VEM)

    interface Message {

    String getMessage() default { return "Look Ma'! Interface with code!";

    }

    }

  • VEM Motivation

    Help to extend existing APIs

    Minimize rewrite of existing API implementation

    eg. Collection API

    eg. Hibernate Collection Implementation

    VEM

  • Collection API Extended

    java.util.functions.*

    java.util.streams.*

    Extension of Iterable, Iterator, Collection, Map, ...

    java.util.Optional

  • Parallel Computing As Easy as 1-2-3?

    myCollection.parallel() .filter(x -> ...) .map(x -> ...) .reduce((x, y) -> ...) // parallel

    myCollection.stream() .filter(x -> ...) .map(x -> ...) .reduce((x, y) -> ...) // sequential

  • Some kata and demos...

  • Project Lambda

  • The Dream Team ;)

    photo: @crazybob

  • Web Sites

    OpenJDK 8 Web site http://openjdk.java.net/projects/lambda/

    JSR335 http://jcp.org/en/jsr/detail?id=335

  • Where to Get Java 8

    Mercurial repo http://hg.openjdk.java.net/lambda/lambda

    Java SE 8 Early Access (with lambda) http://jdk8.java.net/lambda/

  • Mailing Lists

    Technical Discussion mailto:lambda-dev@openjdk.java.net http://mail.openjdk.java.net/pipermail/lambda-dev/

    Libs Spec Discussion http://mail.openjdk.java.net/pipermail/lambda-libs-spec-/

    Spec Discussion http://mail.openjdk.java.net/pipermail/lambda-spec-/

  • Around Project Lambda

    OpenJDK OSX Build (7 & 8) http://code.google.com/p/openjdk-osx-build/

    Java 8 vs Scala: a Feature Comparison http://www.infoq.com/articles/java-8-vs-scala

    H. Gomez

    U. Peter S. van den Berg

  • Around Project Lambda In France

    Curious about Project Lambda ;) http://blog.xebia.fr/ [FR] http://kerflyn.wordpress.com/

    JDK 8: lambdas in Action [FR] http://www.devoxx. com/display/FR12/JDK+8+demo++lambdas+in +Action

    Java 8 et les Lambda [FR] http://thecodersbreakfast.net/index.php? post/2012/05/30/Java-8-et-les-Lambda

    G. Tardif

    O. Croisier

    Guess Who?

  • Project Lambda and the Community ● Transparency

    ○ Presentations / Publications ○ Source code available

    ● Early testing by community ○ Pre-version available ○ AdoptOpenJDK (http://java.

    net/projects/adoptopenjdk/pages/AdoptOpenJDK)

    ● Quick feedback ○ ML, Hackdays

  • Question ● Oneliner, Readability, and Debugability

    ● Java vs. Competitors

    ● What to do for Java 8 to be adopted in projects?

    ● Is there a future for Java?