• Partagez
  • E-mail
  • Intégrer
  • J'aime
  • Télécharger
  • Contenu privé
Functional Groovy - Confess
 

Functional Groovy - Confess

on

  • 1,548 vues

Functional Groovy - Confess

Functional Groovy - Confess

Statistiques

Vues

Total des vues
1,548
Vues sur SlideShare
1,506
Vues externes
42

Actions

J'aime
7
Téléchargements
22
Commentaires
0

1 intégré 42

https://twitter.com 42

Accessibilité

Catégories

Détails de l'import

Uploaded via as Adobe PDF

Droits d'utilisation

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Signalé comme inapproprié Signaler comme inapproprié
Signaler comme inapproprié

Indiquez la raison pour laquelle vous avez signalé cette présentation comme n'étant pas appropriée.

Annuler
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Votre message apparaîtra ici
    Processing...
Poster un commentaire
Modifier votre commentaire

    Functional Groovy - Confess Functional Groovy - Confess Presentation Transcript

    • FUNCTIONAL GROOVY ANDRES ALMIRAY ANDRES.ALMIRAY@CANOO.COM @AALMIRAY
    • ABOUT THE SPEAKERJava developer since the beginningTrue believer in open sourceGroovy committer since 2007Project lead of the Griffon frameworkCurrently working for
    • FUNCTIONALGROOVY,ARE YOUKIDDING ME?
    • GROOVY IS NOTHASKELL RUSSEL WINDER
    • CLOSURES == FUNCTIONSClosures are functions (i.e, blocks of code) with anenvironment containing a binding for all free variables of thefunction
    • CLOSURES == FUNCTIONSClosures are NOT side effect free by design
    • CLOSURES: PARAMETERS (1)Parameter types may be omitted if type information is notneeded
    • CLOSURES: PARAMETERS (2)Parameters may have default valuesNOTE: Default values must be defined from right to left
    • CLOSURES: DEFAULTPARAMETERClosures may have a default parameter named it
    • CLOSURES LEAD TO …IteratorsStreamsPartial EvaluationCompositionMemoizationTail calls
    • ITERATORS (1)
    • ITERATORS (2)p
    • ITERATORS
    • GEEKS & BEERS Functional Java Lambdaj Google Guava
    • USE CASESGiven a list of beers and their prices: Find the cheapest beer Find the most expensive beer What’s the name of the most expensive beer Get all the beer names What’s the total price
    • USE CASE 1Find the cheapest beer
    • USE CASE 2Find the most expensive beer
    • USE CASE 3What’s the name of the most expensive beer
    • USE CASE 4Get all the beer names
    • USE CASE 5What’s the total price
    • PROS & CONSJava collections Non-lazy evaluationClosures! Streams notPlays nice with all included in coreother functional filter/map/reduceframeworksMetaprogramming!
    • S/COLLECT/MAP/Don’t like collect? Use Groovy’s metaprogramming
    • STREAMS (1)Lazy generators. Extension module created by @tim_yateshttp://timyates.github.com/groovy-stream/
    • STREAMS (2)Groovy is Java friendly. Use any Java library such asfunctional-java
    • FJ MODULE EXTENSIONhttps://github.com/mperry/functionalgroovy
    • STREAMS (JDK8)Collection and Lambda friendly, lazy evaluation
    • STREAMS (JDK8)https://twitter.com/jodastephen/status/316991150672183297
    • PARTIAL EVALUATION (1)Currying creates a new closure with fixed parameters, left toright
    • PARTIAL EVALUATION (2)Currying may be applied right to left too, even on an arbitraryindex
    • OBJECTS AS PARTIAL EVALSAny class may implement the call() method, enabling implicitevaluation
    • COMPOSITION (1)Closures may be composed (left to right) using the >>operator
    • COMPOSITION (2)Closures may be composed (right to left) using the <<operator
    • MEMOIZATIONCache computed values for increased performance
    • TAIL CALLS (1)Recursive closures may use Tail Calls thanks to trampoline()
    • TAIL CALLS (2)Apply @TailRecursive on methodshttps://github.com/jlink/tailrec/
    • METHODS AS CLOSURESAny method may be transformed to a Closure using the .&operator
    • IMMUTABILITYThe @Immutable AST transformation makes writingimmutable classes trivial
    • GPARShttp://gpars.codehaus.org/ Concurrent collection processing Composable asynchronous functions Fork/Join abstraction Actor programming model Dataflow concurrency constructs CSP Agent - an thread-safe reference to mutable state
    • PARALLEL COLLECTIONSGpars enhances JDK/GDK collections with parallel executionenabled versions
    • MONADShttps://github.com/dsrkoc/monadologie
    • RESOURCES•  http://pragprog.com/magazines/2013-01/using- memoization-in-groovy•  http://www.ibm.com/developerworks/views/java/ libraryview.jsp?search_by=functional+thinking•  https://github.com/jlink/tailrec/•  http://timyates.github.com/groovy-stream•  http://www.jroller.com/vaclav•  http://gpars.codehaus.org•  http://www.slideshare.net/arturoherrero/functional- programming-with-groovy
    • HTTP://PEOPLE.CANOO.COM/SHARE ANDRES ALMIRAY ANDRES.ALMIRAY@CANOO.COM @AALMIRAY