SlideShare a Scribd company logo
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 ?

More Related Content

What's hot

All about scala
All about scalaAll about scala
All about scala
Yardena Meymann
 
Scala - brief intro
Scala - brief introScala - brief intro
Scala - brief intro
Razvan Cojocaru
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
andyrobinson8
 
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
Paulo Morgado
 
Hammurabi
HammurabiHammurabi
Hammurabi
Mario Fusco
 
Workshop Scala
Workshop ScalaWorkshop Scala
Workshop Scala
Bert Van Vreckem
 
Predictably
PredictablyPredictably
Predictablyztellman
 
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
Derek Chen-Becker
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of Abstraction
Alex Miller
 
core.logic introduction
core.logic introductioncore.logic introduction
core.logic introduction
Norman Richards
 
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
The Software House
 
Scala cheatsheet
Scala cheatsheetScala cheatsheet
Scala cheatsheet
Arduino Aficionado
 
ES6 in Real Life
ES6 in Real LifeES6 in Real Life
ES6 in Real Life
Domenic Denicola
 
2.1 Recap From Day One
2.1 Recap From Day One2.1 Recap From Day One
2.1 Recap From Day Oneretronym
 
Naïveté vs. Experience
Naïveté vs. ExperienceNaïveté vs. Experience
Naïveté vs. Experience
Mike Fogus
 

What's hot (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
 

Viewers also liked

Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
Peter Maas
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Rahul Jain
 
Scala jeff
Scala jeffScala jeff
Scala jeffjeff kit
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java Programmers
Enno 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
 
Scala vs Ruby
Scala vs RubyScala vs Ruby
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Mohammad Hossein Rimaz
 
Microservices and Redis #redisconf Keynote
Microservices and Redis #redisconf KeynoteMicroservices and Redis #redisconf Keynote
Microservices and Redis #redisconf Keynote
Chris Richardson
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
Alex Payne
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
Tim 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
 

Viewers also liked (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 to Scala vs java 8

Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
Skills Matter
 
Scala clojure techday_2011
Scala clojure techday_2011Scala clojure techday_2011
Scala clojure techday_2011
Thadeu 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 framework
Felipe
 
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 2009
Martin 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 Oredev
Mattias 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 2010
scdn
 
Jet presentation
Jet presentationJet presentation
Jet presentation
Peter Sellars
 
CMPT470-usask-guest-lecture
CMPT470-usask-guest-lectureCMPT470-usask-guest-lecture
CMPT470-usask-guest-lecture
Masud 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 Eclipse
Coen 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.Proto
Joel 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 Tongues
CHOOSE
 

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

Recently uploaded

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

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 ?