SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
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 ?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (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
 

Destacado

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
 

Destacado (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...
 

Similar a 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
 

Similar a 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
 

Último

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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 ?