jsr 335: project lambda€¦ · jsr337 java roadmap java 8 aug. 2013 java 7 jul. 2011 java 9? fp /...
TRANSCRIPT
![Page 1: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/1.jpg)
JSR 335:Project LambdaFrançois Sarradin -- Xebia
λ
![Page 2: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/2.jpg)
JSR337
Java RoadmapJava 8
aug. 2013Java 7
jul. 2011 Java 9?
● FP / Parallel comp.● Date API improv.● Type annotation● Compact profiles● Nashorn
ModularityPerformanceProductivity
![Page 3: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/3.jpg)
Project LambdaWhat's in it?
Project Lambda
JSR335
Collection API Bulk Operations
Lambda Expression Virtual Extension Method
Collection API Parallel CollectionsFunctional API
![Page 4: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/4.jpg)
Question
What will be the impactof Project Lambdaon the Java world?
![Page 5: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/5.jpg)
AnswerLook at Speed Car!
![Page 6: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/6.jpg)
Planning...Presentation + live coding (free to interrupt)
● Genesis
● Lambda of Java
● Project Lambda
![Page 7: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/7.jpg)
...And Then● Debate
● Retrospective (agile style!)
● Report○ Xebia blog○ Project Lambda ML
![Page 8: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/8.jpg)
Genesis
![Page 9: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/9.jpg)
More Processors
![Page 10: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/10.jpg)
More ExpressivenessMore Readability
结果 汉字 = new 物().処理();
vs.
fact n = product [1..n]
Is it all Chinese to you?
![Page 11: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/11.jpg)
FP & Competition
Guava
Clojure
C# / F#C++
![Page 12: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/12.jpg)
(Anonymous) Inner ClassA λ Solution
Iterables.filter(persons, new Predicate<Person>() {
@Overridepublic boolean apply(Person person) {
return person.getAge() >= 18;}
}); // Java + Guava
![Page 13: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/13.jpg)
This is what you really need!
Iterables.filter(persons, IS_ADULT);
Predicate<Person> IS_ADULT= new Predicate<Person>() {
@Overridepublic boolean apply(Person person) {
return person.getAge() >= 18;}
});
(Anonymous) Inner ClassA (better?) λ Solution
![Page 14: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/14.jpg)
(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)
![Page 15: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/15.jpg)
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)
![Page 16: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/16.jpg)
Lambda of Java
![Page 17: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/17.jpg)
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; }
![Page 18: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/18.jpg)
Other λ forms
m -> {m.put("France", "Paris");m.put("UK", "London");m.put("USA", "Washington");
}
x -> 2 * x
() -> 42
![Page 19: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/19.jpg)
Inner Classvs. λ SolutionIterables.filter(persons, new Predicate<Person>() {
@Overridepublic boolean apply(Person p) {
return p.getAge() >= 18;}
}); // Java 5-7 + Guava
Iterables.filter(persons, // Java 8 + Guavap -> p.getAge() >= 18);
![Page 20: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/20.jpg)
Method Reference
String::valueOf// like: v -> String.valueOf(v)
Integer::compare// like: (i1, i2) -> Integer.compare(i1, i2)
Arrays.sort(myInts, Integer::compare)
![Page 21: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/21.jpg)
Virtual Extension Method(VEM)
interface Message {
String getMessage() default {return "Look Ma'! Interface with code!";
}
}
![Page 22: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/22.jpg)
VEMMotivation
Help to extend existing APIs
Minimize rewrite of existing API implementation
eg. Collection API
eg. Hibernate Collection Implementation
VEM
![Page 23: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/23.jpg)
Collection API Extended
java.util.functions.*
java.util.streams.*
Extension of Iterable, Iterator, Collection, Map, ...
java.util.Optional
![Page 24: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/24.jpg)
Parallel ComputingAs 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
![Page 25: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/25.jpg)
Some kata and demos...
![Page 26: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/26.jpg)
Project Lambda
![Page 27: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/27.jpg)
The Dream Team ;)
photo: @crazybob
![Page 28: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/28.jpg)
Web Sites
OpenJDK 8 Web sitehttp://openjdk.java.net/projects/lambda/
JSR335http://jcp.org/en/jsr/detail?id=335
![Page 29: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/29.jpg)
Where to Get Java 8
Mercurial repohttp://hg.openjdk.java.net/lambda/lambda
Java SE 8 Early Access (with lambda)http://jdk8.java.net/lambda/
![Page 30: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/30.jpg)
Mailing Lists
Technical Discussionmailto:[email protected]://mail.openjdk.java.net/pipermail/lambda-dev/
Libs Spec Discussionhttp://mail.openjdk.java.net/pipermail/lambda-libs-spec-<*>/
Spec Discussionhttp://mail.openjdk.java.net/pipermail/lambda-spec-<*>/
![Page 31: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/31.jpg)
Around Project Lambda
OpenJDK OSX Build (7 & 8)http://code.google.com/p/openjdk-osx-build/
Java 8 vs Scala: a Feature Comparisonhttp://www.infoq.com/articles/java-8-vs-scala
H. Gomez
U. PeterS. van den Berg
![Page 32: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/32.jpg)
Around Project LambdaIn 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?
![Page 33: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/33.jpg)
Project Lambdaand 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
![Page 34: JSR 335: Project Lambda€¦ · JSR337 Java Roadmap Java 8 aug. 2013 Java 7 jul. 2011 Java 9? FP / Parallel comp. Date API improv. Type annotation Compact profiles Nashorn](https://reader035.vdocuments.site/reader035/viewer/2022081505/5ed68327ff0e593c0b63fb64/html5/thumbnails/34.jpg)
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?