SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
Scala
     vs
      Java 8
List("Sarradin", "Armand")
    .map("François " + _)


                     2012-12-20
François Sarradin
Xebia
Twitter: @fsarradin
Blog: http://kerflyn.wordpress.com/




                                      François Armand
                                             Normation
                                          Twitter: @fanf42
Dernier PSUG
Avant la fin du monde
Pourquoi cette présentation
           (au PSUG ?)



!!! DISCLAIMER !!!
● Pas de troll
● Ni monade, ni typeclass
● Pas de conflit d'intérêt
● Vous avez le droit de parler aux chauffeurs
À venir



● Présentation de concepts

● Faire des trucs avec les concepts

● Parler des concepts
Java 8
Plus de Processeurs
Plus d'Expressivité
Plus de Lisibilité



  结果 汉字 = new 物().処理();
                 vs.
   fact n = product [1..n]


               Is it all Chinese to you?
FP & Concurrence




               C++
                   C# / F#
     Clojure        Guava
(Anonymous) Inner Class
Une Solution λ


adults = Iterables.filter(persons,
 new Predicate<Person>() {

  @Override
  public boolean apply(Person person) {
    return person.getAge() >= 18;
  }

}); // Java + Guava
(Anonymous) Inner Class
Une Solution λ


adults = Iterables.filter(persons,
 new Predicate<Person>() {

  @Override
  public boolean apply(Person person) {
    return person.getAge() >= 18;
  }

}); // Java + Guava
(Anonymous) Inner Class
(Pas Vraiment) Une Solution λ


● "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)



        Average length of Java one-liner is 21 line!
        @DEVOPS_BORAT - 12/09/2011
λ Project     Date and Time
                      (JSR 335)     API (JSR 310) Project Coin
Nashorn
                                                    (JSR ?)
   Performance                     Productivité
                                             Annotation on
                                            Types (JSR 308)

                      Java 8
                      (JSR 337)



     Project Jigsaw   Modularité
        (JSR ?)                            Java 9
[New]
                 Method Reference                   [New] Interface Method
  [New]           T::m T::new                      default void m()...
x -> f(x)            obj::m
                                                    Virtual
        λ Expression                 Change in     Extension
                                       Property
                                    Inheritance     Method
Type Inference                                                          [New]
   Engine                                                    Static Method in
Enhancement                                                          Interface
                            λ Project
                             (JSR 335)



                              Collection
                                                  [New]
                       API Extension       Parallel Collections
Une Lambda Expression




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




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




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



Scala
(x:Int, y:Int) => x + y
Une Lambda Expression




(x, y) -> x + y



Scala
(x, y) => x + y
D'autres formes de λ


x   -> 2 * x

() -> 42

m   -> {
    m.put("France", "Paris");
    m.put("UK", "London");
    m.put("USA", "Washington");
}
Inner Class vs λ Solution

Iterables.filter(persons,
 new Predicate<Person>() {
   @Override
   public boolean apply(Person p) {
     return p.getAge() >= 18;
   }
}); // Java 5-7 + Guava


Iterables.filter(persons, // Java 8 + Guava
     person -> person.getAge() >= 18);
λ = SAM
(Single Abstract Method)


● Indépendant du type

● Une et une seule méthode abstraite

● Fonctionne avec
  ○ Runnable, Callable, Comparator
  ○ JDK's function API, Guava API
  ○ types persos, ...
λ et variables externes



int x = 1;    => Implicitement final

y -> y + x;

x = 2;
Method Reference

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

String::new
// like: v -> new String(v)

myBigDecimal::add
// like: (n) -> myBigDecimal.add(n)


Arrays.sort(myInts, Integer::compare)
Virtual Extension Method
    (VEM)



interface Message {

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

}
VEM : Dangereux ?



● Brian Goetz : NON
  ○ Héritage de comportement uniquement


● François Sarradin : OUI O_O'
  ○ Article : "Java 8: Now You Have Mixins?"
  ○ (Voir les kata)
Faire évoluer les APIs




● "APIs need a mechanism for evolving, or they will
  become increasingly constraining to use, and replacing
  them is expensive." (Brian Goetz - 07/2012)
Parallel Computing
Aussi simple que 1-2-3 ?

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



myCollection.parallel()
   .filter(x -> ...)
   .map(x -> ...)
   .reduce((x, y) -> ...) // parallel
The Dream Team ;)




                    photo: @crazybob
Java 8
Sites Web

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


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


Mailing List
mailto:lambda-dev@openjdk.java.net
http://mail.openjdk.java.net/pipermail/lambda-dev/
Et maintenant,
scéance de code
    in vivo...
Questions ?
● Adoption de Java 8 / Scala ?

● Debuggage ?

● Utilisation des Lambda Java 8 en Scala ?

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

All about scala
All about scalaAll about scala
All about scala
 
Scala - brief intro
Scala - brief introScala - brief intro
Scala - brief intro
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
Hammurabi
HammurabiHammurabi
Hammurabi
 
Workshop Scala
Workshop ScalaWorkshop Scala
Workshop Scala
 
Predictably
PredictablyPredictably
Predictably
 
Scala for Java programmers
Scala for Java programmersScala for Java programmers
Scala for Java programmers
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
scala
scalascala
scala
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of Abstraction
 
core.logic introduction
core.logic introductioncore.logic introduction
core.logic introduction
 
Let the type system be your friend
Let the type system be your friendLet the type system be your friend
Let the type system be your friend
 
Scala
ScalaScala
Scala
 
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
 
2.1 Recap From Day One
2.1 Recap From Day One2.1 Recap From Day One
2.1 Recap From Day One
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
 
Scala on Android
Scala on AndroidScala on Android
Scala on Android
 

Andere mochten auch

Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To ScalaPeter Maas
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
Scala jeff
Scala jeffScala jeff
Scala jeffjeff kit
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java ProgrammersEnno Runne
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?Alex Payne
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.Brian Hsu
 
Microservices in Java and Scala (sfscala)
Microservices in Java and Scala (sfscala)Microservices in Java and Scala (sfscala)
Microservices in Java and Scala (sfscala)Chris Richardson
 
Microservices and Redis #redisconf Keynote
Microservices and Redis #redisconf KeynoteMicroservices and Redis #redisconf Keynote
Microservices and Redis #redisconf KeynoteChris Richardson
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to ScalaTim Underwood
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Chris Richardson
 
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...Helena Edelson
 

Andere mochten auch (14)

Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala jeff
Scala jeffScala jeff
Scala jeff
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java Programmers
 
Why Scala for Web 2.0?
Why Scala for Web 2.0?Why Scala for Web 2.0?
Why Scala for Web 2.0?
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
 
Microservices in Java and Scala (sfscala)
Microservices in Java and Scala (sfscala)Microservices in Java and Scala (sfscala)
Microservices in Java and Scala (sfscala)
 
Scala vs Ruby
Scala vs RubyScala vs Ruby
Scala vs Ruby
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Microservices and Redis #redisconf Keynote
Microservices and Redis #redisconf KeynoteMicroservices and Redis #redisconf Keynote
Microservices and Redis #redisconf Keynote
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
 
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
Lambda Architecture with Spark, Spark Streaming, Kafka, Cassandra, Akka and S...
 

Ähnlich wie Scala vs java 8

Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011Thadeu Russo
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play frameworkFelipe
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingGarth Gilmour
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotВладимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotVolha Banadyseva
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Coen De Roover
 
Java one 2010
Java one 2010Java one 2010
Java one 2010scdn
 
CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureMasud Rahman
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLsintelliyole
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondMario Fusco
 
Logic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseLogic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseCoen De Roover
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoJoel Falcou
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 

Ähnlich wie Scala vs java 8 (20)

Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011
 
Short intro to scala and the play framework
Short intro to scala and the play frameworkShort intro to scala and the play framework
Short intro to scala and the play framework
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpotВладимир Иванов. Java 8 и JVM: что нового в HotSpot
Владимир Иванов. Java 8 и JVM: что нового в HotSpot
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012Ekeko Technology Showdown at SoTeSoLa 2012
Ekeko Technology Showdown at SoTeSoLa 2012
 
Java one 2010
Java one 2010Java one 2010
Java one 2010
 
Jet presentation
Jet presentationJet presentation
Jet presentation
 
CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lecture
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
 
Logic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with EclipseLogic-based program transformation in symbiosis with Eclipse
Logic-based program transformation in symbiosis with Eclipse
 
Java 7
Java 7Java 7
Java 7
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.Proto
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 

Kürzlich hochgeladen

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Kürzlich hochgeladen (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Scala vs java 8

  • 1. Scala vs Java 8 List("Sarradin", "Armand") .map("François " + _) 2012-12-20
  • 2. François Sarradin Xebia Twitter: @fsarradin Blog: http://kerflyn.wordpress.com/ François Armand Normation Twitter: @fanf42
  • 3. Dernier PSUG Avant la fin du monde
  • 4. Pourquoi cette présentation (au PSUG ?) !!! DISCLAIMER !!! ● Pas de troll ● Ni monade, ni typeclass ● Pas de conflit d'intérêt ● Vous avez le droit de parler aux chauffeurs
  • 5. À venir ● Présentation de concepts ● Faire des trucs avec les concepts ● Parler des concepts
  • 8. Plus d'Expressivité Plus de Lisibilité 结果 汉字 = new 物().処理(); vs. fact n = product [1..n] Is it all Chinese to you?
  • 9. FP & Concurrence C++ C# / F# Clojure Guava
  • 10. (Anonymous) Inner Class Une Solution λ adults = Iterables.filter(persons, new Predicate<Person>() { @Override public boolean apply(Person person) { return person.getAge() >= 18; } }); // Java + Guava
  • 11. (Anonymous) Inner Class Une Solution λ adults = Iterables.filter(persons, new Predicate<Person>() { @Override public boolean apply(Person person) { return person.getAge() >= 18; } }); // Java + Guava
  • 12. (Anonymous) Inner Class (Pas Vraiment) Une Solution λ ● "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) Average length of Java one-liner is 21 line! @DEVOPS_BORAT - 12/09/2011
  • 13. λ Project Date and Time (JSR 335) API (JSR 310) Project Coin Nashorn (JSR ?) Performance Productivité Annotation on Types (JSR 308) Java 8 (JSR 337) Project Jigsaw Modularité (JSR ?) Java 9
  • 14. [New] Method Reference [New] Interface Method [New] T::m T::new default void m()... x -> f(x) obj::m Virtual λ Expression Change in Extension Property Inheritance Method Type Inference [New] Engine Static Method in Enhancement Interface λ Project (JSR 335) Collection [New] API Extension Parallel Collections
  • 15. Une Lambda Expression (int x, int y) -> { return x + y; }
  • 16. Une Lambda Expression (x, y) -> { return x + y; }
  • 17. Une Lambda Expression (int x, int y) -> x + y Scala (x:Int, y:Int) => x + y
  • 18. Une Lambda Expression (x, y) -> x + y Scala (x, y) => x + y
  • 19. D'autres formes de λ x -> 2 * x () -> 42 m -> { m.put("France", "Paris"); m.put("UK", "London"); m.put("USA", "Washington"); }
  • 20. Inner Class vs λ Solution Iterables.filter(persons, new Predicate<Person>() { @Override public boolean apply(Person p) { return p.getAge() >= 18; } }); // Java 5-7 + Guava Iterables.filter(persons, // Java 8 + Guava person -> person.getAge() >= 18);
  • 21.
  • 22. λ = SAM (Single Abstract Method) ● Indépendant du type ● Une et une seule méthode abstraite ● Fonctionne avec ○ Runnable, Callable, Comparator ○ JDK's function API, Guava API ○ types persos, ...
  • 23. λ et variables externes int x = 1; => Implicitement final y -> y + x; x = 2;
  • 24. Method Reference String::valueOf // like: v -> String.valueOf(v) String::new // like: v -> new String(v) myBigDecimal::add // like: (n) -> myBigDecimal.add(n) Arrays.sort(myInts, Integer::compare)
  • 25. Virtual Extension Method (VEM) interface Message { default String getMessage() { return "Look Ma'! Interface with code!"; } }
  • 26.
  • 27. VEM : Dangereux ? ● Brian Goetz : NON ○ Héritage de comportement uniquement ● François Sarradin : OUI O_O' ○ Article : "Java 8: Now You Have Mixins?" ○ (Voir les kata)
  • 28. Faire évoluer les APIs ● "APIs need a mechanism for evolving, or they will become increasingly constraining to use, and replacing them is expensive." (Brian Goetz - 07/2012)
  • 29. Parallel Computing Aussi simple que 1-2-3 ? myCollection.stream() .filter(x -> ...) .map(x -> ...) .reduce((x, y) -> ...) // sequential myCollection.parallel() .filter(x -> ...) .map(x -> ...) .reduce((x, y) -> ...) // parallel
  • 30. The Dream Team ;) photo: @crazybob
  • 31. Java 8 Sites Web Java SE 8 Early Access (with lambda) http://jdk8.java.net/lambda/ Mercurial repo http://hg.openjdk.java.net/lambda/lambda Mailing List mailto:lambda-dev@openjdk.java.net http://mail.openjdk.java.net/pipermail/lambda-dev/
  • 32. Et maintenant, scéance de code in vivo...
  • 33. Questions ? ● Adoption de Java 8 / Scala ? ● Debuggage ? ● Utilisation des Lambda Java 8 en Scala ?