Java 8 Lambda

download Java 8 Lambda

of 34

  • date post

    26-Jan-2015
  • Category

    Technology

  • view

    115
  • download

    3

Embed Size (px)

description

 

Transcript of Java 8 Lambda

  • 1. JSR 335: Project LambdaFranois Sarradin -- Xebia

2. Java Roadmap 337 Java 7 JSR Java 8jul. 2011aug. 2013Java 9?ModularityPerformance FP / Parallel comp. Productivity Date API improv. Type annotation Compact profiles Nashorn 3. Project LambdaWhats in it?ProjectLambdaJSR335Virtual ExtensionLambda Expression MethodCollection API Collection APIFunctional API Parallel CollectionsBulk Operations 4. Question What will be the impactof Project Lambdaon the Java world? 5. AnswerLook at Speed Car! 6. Planning...Presentation + live coding (free to interrupt) Genesis Lambda of Java Project Lambda 7. ...And Then Debate Retrospective (agile style!) Report Xebia blog Project Lambda ML 8. Genesis 9. More Processors 10. More ExpressivenessMore Readability = new ().(); vs.fact n = product [1..n] Is it all Chinese to you? 11. FP & CompetitionClojure C++C# / F# Guava 12. (Anonymous) Inner ClassA SolutionIterables.filter(persons, new Predicate() {@Overridepublic boolean apply(Person person) {return person.getAge() >= 18;}}); // Java + Guava 13. (Anonymous) Inner ClassA (better?) SolutionIterables.filter(persons, IS_ADULT);Predicate IS_ADULT = new Predicate() {@Overridepublic boolean apply(Person person) {return person.getAge() >= 18;}});This is what you really need! 14. (Anonymous) Inner Class(Not Really) A Solution "The pain of anonymous inner classes makes us rollour eyes in the back of our heads every day." (a wiseOracles client, 01/2011) Average length of Java one-liner is 21 line! @DEVOPS_BORAT - 12/09/2011 15. What about Oracle? "Its time to add closures to Java" (Mark Reinhold, 12/2009) "Oracles position is that Java must evolve -- carefully, of course -- in order to remain competitive." (Brian Goetz - 08/2011) 16. Lambda of Java 17. Here is the !(int x, int y) -> { return x + y; }(x, y) -> { return x + y; }(int x, int y) -> x + y(x, y) -> x + y 18. Other formsx -> 2 * x() -> 42m -> {m.put("France", "Paris");m.put("UK", "London");m.put("USA", "Washington");} 19. Inner Classvs. SolutionIterables.filter(persons, new Predicate() { @Override public boolean apply(Person p) { return p.getAge() >= 18; }}); // Java 5-7 + GuavaIterables.filter(persons, // Java 8 + Guava p -> p.getAge() >= 18); 20. Method ReferenceString::valueOf// like: v -> String.valueOf(v)Integer::compare// like: (i1, i2) -> Integer.compare(i1, i2)Arrays.sort(myInts, Integer::compare) 21. Virtual Extension Method(VEM)interface Message {String getMessage() default {return "Look Ma! Interface with code!";}} 22. VEMMotivation VEMeg. Collection API Help to extend existing APIs Minimize rewrite of existing API implementationeg. Hibernate CollectionImplementation 23. Collection API Extendedjava.util.functions.*java.util.streams.*Extension of Iterable, Iterator, Collection, Map, ...java.util.Optional 24. Parallel ComputingAs Easy as 1-2-3?myCollection.stream() .filter(x -> ...) .map(x -> ...) .reduce((x, y) -> ...) // sequentialmyCollection.parallel() .filter(x -> ...) .map(x -> ...) .reduce((x, y) -> ...) // parallel 25. Some kata and demos... 26. Project Lambda 27. The Dream Team ;)photo: @crazybob 28. Web SitesJSR335http://jcp.org/en/jsr/detail?id=335OpenJDK 8 Web sitehttp://openjdk.java.net/projects/lambda/ 29. Where to Get Java 8Java SE 8 Early Access (with lambda)http://jdk8.java.net/lambda/Mercurial repohttp://hg.openjdk.java.net/lambda/lambda 30. Mailing ListsTechnical Discussionmailto:lambda-dev@openjdk.java.nethttp://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-/ 31. Around Project LambdaOpenJDK OSX Build (7 & 8)http://code.google.com/p/openjdk-osx-build/ H. GomezJava 8 vs Scala: a FeatureComparisonhttp://www.infoq.com/articles/java-8-vs-scalaS. van den BergU. Peter 32. Around Project LambdaIn FranceJDK 8: lambdas in Action [FR]http://www.devoxx. O. Croisiercom/display/FR12/JDK+8+demo++lambdas+in+Action G. TardifJava 8 et les Lambda [FR]http://thecodersbreakfast.net/index.php?post/2012/05/30/Java-8-et-les-LambdaCurious about Project Lambda ;)http://blog.xebia.fr/ [FR]http://kerflyn.wordpress.com/Guess Who? 33. 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 34. Question Oneliner, Readability, and Debugability Java vs. Competitors What to do for Java 8 to be adopted inprojects? Is there a future for Java?