SlideShare a Scribd company logo
GETTING 
FUNKY 
WITH 
ANDRES ALMIRAY IX-CHEL RUIZ 
@AALMIRAY @IXCHELRUIZ
Javaone - Getting Funky with Groovy
Javaone - Getting Funky with Groovy
Javaone - Getting Funky with Groovy
FUNCTIONAL 
GROOVY, 
ARE YOU 
KIDDING ME?
GROOVY IS NOT 
HASKELL 
RUSSEL WINDER 
* have a look at https://github.com/frege/frege
CLOSURES == FUNCTIONS 
Closures are functions (i.e, blocks of code) with an 
environment containing a binding for all free variables of the 
function
CLOSURES == FUNCTIONS 
Closures are NOT side effect free by design
CLOSURES: PARAMETERS (1) 
Parameter types may be omitted if type information is not 
needed
CLOSURES: PARAMETERS (2) 
Parameters may have default values 
NOTE: Default values must be defined from right to left
CLOSURES: DEFAULT 
PARAMETER 
Closures may have a default parameter named it
CLOSURES LEAD TO … 
Iterators 
Streams 
Partial Evaluation 
Composition 
Memoization 
Tail calls
ITERATORS (1)
ITERATORS (2) 
p
ITERATORS
GEEKS & BEERS 
Mattias Johan 
Functional Java 
Lambdaj 
Google Guava
USE CASES 
Given 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 1 
Find the cheapest beer
USE CASE 2 
Find the most expensive beer
USE CASE 3 
What’s the name of the most expensive beer
USE CASE 4 
Get all the beer names
USE CASE 5 
What’s the total price
PROS & CONS 
Java collections 
Closures! 
Plays nice with all 
other functional 
frameworks 
Metaprogramming! 
Non-lazy evaluation 
Streams not 
included in core 
filter/map/reduce
S/COLLECT/MAP/ 
Don’t like collect? Use Groovy’s metaprogramming
STREAMS (1) 
Lazy generators. Extension module created by @tim_yates 
http://timyates.github.com/groovy-stream/
STREAMS (2) 
Groovy is Java friendly. Use any Java library such as 
functional-java
FJ MODULE EXTENSION 
https://github.com/mperry/functionalgroovy 
Update: Mark has posted some notes at 
http://mperry.github.io/2013/07/28/groovy-null-handling.html
STREAMS (JDK8) 
Collection and Lambda friendly, lazy evaluation
PARTIAL EVALUATION (1) 
Currying creates a new closure with fixed parameters, left to 
right
PARTIAL EVALUATION (2) 
Currying may be applied right to left too, even on an arbitrary 
index
OBJECTS AS PARTIAL EVALS 
Any class may implement the call() method, enabling implicit 
evaluation
COMPOSITION (1) 
Closures may be composed (left to right) using the >> 
operator
COMPOSITION (2) 
Closures may be composed (right to left) using the << 
operator
MEMOIZATION 
Cache computed values for increased performance
TAIL CALLS (1) 
Recursive closures may use Tail Calls thanks to trampoline()
TAIL CALLS (2) 
Apply @TailRecursive on methods 
https://github.com/jlink/tailrec/ 
now included in Groovy 2.3!
METHODS AS CLOSURES 
Any method may be transformed to a Closure using the .& 
operator
IMMUTABILITY 
The @Immutable AST transformation makes writing 
immutable classes trivial
GPARS 
http://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 COLLECTIONS 
Gpars enhances JDK/GDK collections with parallel execution 
enabled versions
MONADS 
https://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
THANK YOU! 
HTTP://PEOPLE.CANOO.COM/SHARE 
Andres Almiray Ix-chel Ruiz 
@aalmiray @ixchelruiz

More Related Content

What's hot (11)

PPTX
A Brief Conceptual Introduction to Functional Java 8 and its API
Jörn Guy Süß JGS
 
PDF
Reactive programming with tracker
Designveloper
 
PDF
Groovy AST Demystified
Andres Almiray
 
PDF
PuppetConf 2014 Killer R10K Workflow Without Notes
Phil Zimmerman
 
PPTX
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Gesh Markov
 
PPTX
C compilation process
RajKumar Rampelli
 
PDF
Command Line Arguments with Getopt::Long
Ian Kluft
 
PDF
Golang
Felipe Mamud
 
PDF
Parallel program design
ZongYing Lyu
 
PDF
kikstart journey of Golang with Hello world - Gopherlabs
sangam biradar
 
PPTX
Kotlin For Android - Basics (part 1 of 7)
Gesh Markov
 
A Brief Conceptual Introduction to Functional Java 8 and its API
Jörn Guy Süß JGS
 
Reactive programming with tracker
Designveloper
 
Groovy AST Demystified
Andres Almiray
 
PuppetConf 2014 Killer R10K Workflow Without Notes
Phil Zimmerman
 
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Gesh Markov
 
C compilation process
RajKumar Rampelli
 
Command Line Arguments with Getopt::Long
Ian Kluft
 
Golang
Felipe Mamud
 
Parallel program design
ZongYing Lyu
 
kikstart journey of Golang with Hello world - Gopherlabs
sangam biradar
 
Kotlin For Android - Basics (part 1 of 7)
Gesh Markov
 

Similar to Javaone - Getting Funky with Groovy (20)

PDF
Functional Groovy - Confess
Andres Almiray
 
PDF
Learning groovy -EU workshop
adam1davis
 
PDF
Functional Programming in Groovy
Evgeny Goldin
 
ODP
Learning groovy 1: half day workshop
Adam Davis
 
PDF
Introduction to Groovy (Serbian Developer Conference 2013)
Joachim Baumann
 
PDF
Groovy.pptx
Giancarlo Frison
 
PPT
Groovy presentation
Manav Prasad
 
PDF
Introductionto fp with groovy
Isuru Samaraweera
 
PDF
javerosmx-2015-marzo-groovy-java8-comparison
Domingo Suarez Torres
 
PDF
Apache Groovy: the language and the ecosystem
Kostas Saidis
 
PDF
What's in Groovy for Functional Programming
Naresha K
 
PDF
An Introduction to Groovy for Java Developers
Kostas Saidis
 
PPTX
Groovy closures
Vijay Shukla
 
PPT
Groovy unleashed
Isuru Samaraweera
 
KEY
Polyglot and Functional Programming (OSCON 2012)
Martijn Verburg
 
PPTX
Groovy And Grails Introduction
Eric Weimer
 
PDF
GPars For Beginners
Matt Passell
 
PDF
Functional Programming in Clojure
Troy Miles
 
PDF
Groovy On Trading Desk (2010)
Jonathan Felch
 
PDF
Introduction to Oracle Groovy
Deepak Bhagat
 
Functional Groovy - Confess
Andres Almiray
 
Learning groovy -EU workshop
adam1davis
 
Functional Programming in Groovy
Evgeny Goldin
 
Learning groovy 1: half day workshop
Adam Davis
 
Introduction to Groovy (Serbian Developer Conference 2013)
Joachim Baumann
 
Groovy.pptx
Giancarlo Frison
 
Groovy presentation
Manav Prasad
 
Introductionto fp with groovy
Isuru Samaraweera
 
javerosmx-2015-marzo-groovy-java8-comparison
Domingo Suarez Torres
 
Apache Groovy: the language and the ecosystem
Kostas Saidis
 
What's in Groovy for Functional Programming
Naresha K
 
An Introduction to Groovy for Java Developers
Kostas Saidis
 
Groovy closures
Vijay Shukla
 
Groovy unleashed
Isuru Samaraweera
 
Polyglot and Functional Programming (OSCON 2012)
Martijn Verburg
 
Groovy And Grails Introduction
Eric Weimer
 
GPars For Beginners
Matt Passell
 
Functional Programming in Clojure
Troy Miles
 
Groovy On Trading Desk (2010)
Jonathan Felch
 
Introduction to Oracle Groovy
Deepak Bhagat
 
Ad

More from Andres Almiray (20)

PDF
Dealing with JSON in the relational world
Andres Almiray
 
PDF
Deploying to production with confidence 🚀
Andres Almiray
 
PDF
Going beyond ORMs with JSON Relational Duality Views
Andres Almiray
 
PDF
Setting up data driven tests with Java tools
Andres Almiray
 
PDF
Creando, creciendo, y manteniendo una comunidad de codigo abierto
Andres Almiray
 
PDF
Liberando a produccion con confianza
Andres Almiray
 
PDF
Liberando a produccion con confidencia
Andres Almiray
 
PDF
OracleDB Ecosystem for Java Developers
Andres Almiray
 
PDF
Softcon.ph - Maven Puzzlers
Andres Almiray
 
PDF
Maven Puzzlers
Andres Almiray
 
PDF
Oracle Database Ecosystem for Java Developers
Andres Almiray
 
PDF
JReleaser - Releasing at the speed of light
Andres Almiray
 
PDF
Building modular applications with the Java Platform Module System and Layrry
Andres Almiray
 
PDF
Going Reactive with g rpc
Andres Almiray
 
PDF
Building modular applications with JPMS and Layrry
Andres Almiray
 
PDF
Taking Micronaut out for a spin
Andres Almiray
 
PDF
Apache Groovy's Metaprogramming Options and You
Andres Almiray
 
PDF
What I wish I knew about Maven years ago
Andres Almiray
 
PDF
What I wish I knew about maven years ago
Andres Almiray
 
PDF
The impact of sci fi in tech
Andres Almiray
 
Dealing with JSON in the relational world
Andres Almiray
 
Deploying to production with confidence 🚀
Andres Almiray
 
Going beyond ORMs with JSON Relational Duality Views
Andres Almiray
 
Setting up data driven tests with Java tools
Andres Almiray
 
Creando, creciendo, y manteniendo una comunidad de codigo abierto
Andres Almiray
 
Liberando a produccion con confianza
Andres Almiray
 
Liberando a produccion con confidencia
Andres Almiray
 
OracleDB Ecosystem for Java Developers
Andres Almiray
 
Softcon.ph - Maven Puzzlers
Andres Almiray
 
Maven Puzzlers
Andres Almiray
 
Oracle Database Ecosystem for Java Developers
Andres Almiray
 
JReleaser - Releasing at the speed of light
Andres Almiray
 
Building modular applications with the Java Platform Module System and Layrry
Andres Almiray
 
Going Reactive with g rpc
Andres Almiray
 
Building modular applications with JPMS and Layrry
Andres Almiray
 
Taking Micronaut out for a spin
Andres Almiray
 
Apache Groovy's Metaprogramming Options and You
Andres Almiray
 
What I wish I knew about Maven years ago
Andres Almiray
 
What I wish I knew about maven years ago
Andres Almiray
 
The impact of sci fi in tech
Andres Almiray
 
Ad

Recently uploaded (20)

PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 

Javaone - Getting Funky with Groovy