SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
Groovy & Java 8
A very simple comparison
@ JaverosMX, Mexico City
30/Marzo/2015Domingo Suárez Torres (@domix)
Agenda
• Background
• A little bit about Groovy
• Why is important to upgrade to Java 8
• Comparison
• Very small :’(
Groovy, just a little
• Optionally typed & dynamic language for the
JVM
• Static-typing and static compilation capabilities
• Scripting capabilities, Domain-Specific
Language authoring, runtime and compile-time
meta-programming and functional programming
Seamlessly and transparently
integrates and interoperates with
Java and any third-party libraries
Java 8 matters
• Java 7 EOL. April 2015
• Java 6 < go figure.
• “Brand new” techniques, patterns, paradigms. Built in the language.
• Very soon libraries and frameworks will adopt those improvements.
• Enhancements
• Nashorn
• Invoke-dynamic
• Java 8 arrived late to the party. Better late than never.
Java 8 features
• New Syntax
• Stream API
• Profiles
• JavaFX
• Date/Time API
• Nashorn
• Pack200
• JDBC
• Concurrency
• JAXP
• Hotspot
• Java Mission Control
Java 8 syntax
• Lambda expressions
• Method references
• static & default methods in interfaces
• Repeating annotations
• Annotation on types
• Improved type inference
• Method parameter reflection
Comparison
Feature similarities
• Java 8
• Lambda expressions
• Default methods
• Optional types
• Stream API
• Method references
• Groovy
• Closures
• Traits
• Truth & null handling
• GDK Collections
• Method closures
Code as data
• Interfaces with one method (functional interface)
• Single Abstract Method interfaces (SAM Interfaces)
• Inner classes are annoying due verbosity.
• Java 8 Lambda Expressions, Groovy Closures.
• JVM functions became almost first-class
citizens.
Java 8 Lambdas
Lambda expressions
Groovy Closures
• Since 2003.
• Is an open, anonymous, block of code that can take
arguments.
• Return a value and be assigned to a variable.
• A closure may reference variables declared in its
surrounding scope.
• Can also contain free variables which are defined outside
of its surrounding scope. In opposition to the formal
definition of a closure.
Closures in action
GDK (Groovy Dev Kit)
Closures behind scenes
• Groovy creates an inner anonymous class
• groovy.lang.Closure implements
• Cloneable
• Runnable
• GroovyCallable
• java.util.concurrent.Callable
• Serializable
Java 8 with Groovy
Java 8
Default methods
Default methods
• Non-abstract method implementations to
interfaces by utilizing the default keyword
• Also know as Extension Methods
Default methods
Default methods
• Can be static methods
• We can use them to implement multiple
inheritance
• Naming conflict¡
Groovy Traits
Traits
• The same idea as default methods in Java
• Interface with method bodies
• Can be stateful
• Multiple inheritance
Stream API
java.util.Stream
• Represents a sequence of elements on which one or
more operations can be performed.
• Stream operations are either intermediate or terminal.
• While terminal operations return a result of a certain type,
intermediate operations return the stream itself so you
can chain multiple method calls in a row.
• Streams are created on a source (Collection)
• Stream operations can either be executed sequential or
parallel.
Streams usage
Streams with
method references
Map-Reduce
GDK Collections
Groovy GDK
• Groovy add lots of enhancements into the
standard JDK
• Groovy “injects” additional methods on the
standard Java libraries
• GDK adds syntactic sugar to Java APIs for
better and easier usage.
Using GDK facilities
GDK and Java 8
• Some GDK facilities will be deprecated in favor
of Stream
• Stream is more efficient and performant
• Groovy will focus in better integration with Java 8
enhancements
Java 8 Optionals
java.util.Optional<T>
• NPE is awkward.
• A optional is a container object which may or
may not contain a non-null value.
• Additional methods that depend on the
presence or absence of a contained value are
provided, such as orElse() (return a default value
if value not present) and ifPresent() (execute a
block of code if the value is present).
Optional usage
Stream/Optional
real life example
Groovy Truth
Groovy Truth
• Everything that’s null, empty, zero-sized, equal to
zero is false. Otherwise is true
• Groovy Truth is quite simple: just implement a
custom asBoolean() method.
Null handling in Groovy
What to do?
• IMO, Java 8 is a great release
• Groovy is a madure alternative language for the
JVM
• My recommendation is to use both languages
Java 8 highlights
• Lambdas
• Stream API
• Nashorn. Avatar project
Groovy Highlights
• Traits
• Metaprogramming
• AST Transformations
• DSL authoring
• Android support
• @TypeChecked @CompileStatic
Contact
• @domix
• domingo.suarez@gmail.com
• #JaverosMX
Picture credits
• https://www.flickr.com/photos/eneas/3108310839/
• https://www.flickr.com/photos/eneas/6395912803/
• https://www.flickr.com/photos/80651083@N00/5641290457/
• https://www.flickr.com/photos/annuar_martinez/3282050044/
• https://www.flickr.com/photos/luismontemayor/2550701324/
• https://www.flickr.com/photos/guseher/2393646953/
• https://www.flickr.com/photos/annuar_martinez/2342099774/
• https://www.flickr.com/photos/luismontemayor/4306210583/
• https://www.flickr.com/photos/lastingimages/12262034856/
• https://www.flickr.com/photos/atejada/14169147706/
• https://www.flickr.com/photos/luismontemayor/3018556662/
• https://www.flickr.com/photos/eneas/2290156408/
• https://www.flickr.com/photos/122274109@N03/16154663524/
• https://www.flickr.com/photos/krynowekeine/2755263171/
• https://www.flickr.com/photos/nino_ary/2901716788/
• https://www.flickr.com/photos/eneas/5279761/
• https://www.flickr.com/photos/lastingimages/12373124983/
• https://www.flickr.com/photos/rmgg-photos/8503188042/
• https://www.flickr.com/photos/luajr/15127961825/
• https://www.flickr.com/photos/gtercero/8740734623/
• https://www.flickr.com/photos/egmzcp15/5237066174/
• https://www.flickr.com/photos/rouleau/109405487/
• https://www.flickr.com/photos/xavier333/2257501542/
• https://www.flickr.com/photos/pvcg/3087911579/
• https://www.flickr.com/photos/notocajrs/12785034584/
• https://www.flickr.com/photos/nahual_neo/8005123271/
• https://www.flickr.com/photos/chicotown/3189442699/
• https://www.flickr.com/photos/kootenayhulio/5497898774/
• https://www.flickr.com/photos/maybemaq/16579363326/
• https://www.flickr.com/photos/luajr/15484454837/
Picture credits
• https://www.flickr.com/photos/nahual_neo/4290121443/
• https://www.flickr.com/photos/70120970@N08/8493760801/
• https://www.flickr.com/photos/gustavothomastheatre/15823470423/
• https://www.flickr.com/photos/graficris_lgs/15543907818/
• https://www.flickr.com/photos/gustavothomastheatre/15708898754/
• https://www.flickr.com/photos/john_colby/8430729849/
• https://www.flickr.com/photos/egmzcp15/4144937818/
• https://www.flickr.com/photos/10066932@N03/2552609658/
• https://www.flickr.com/photos/bdebaca/2987372965/
• https://www.flickr.com/photos/beco/23806123

Contenu connexe

Tendances

Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?Weng Wei
 
Intoduction to React
Intoduction to ReactIntoduction to React
Intoduction to ReactRubizza
 
Custom angular libraries
Custom angular librariesCustom angular libraries
Custom angular librariesMattVaughn9
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code baseRobert Munteanu
 
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsJames Williams
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Codemotion
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With JestBen McCormick
 
Why don't you Groovy?
Why don't you Groovy?Why don't you Groovy?
Why don't you Groovy?Orest Ivasiv
 
Ruby in office time reboot
Ruby in office time rebootRuby in office time reboot
Ruby in office time rebootKentaro Goto
 
The Saga of JavaScript and TypeScript: Part 1
The Saga of JavaScript and TypeScript: Part 1The Saga of JavaScript and TypeScript: Part 1
The Saga of JavaScript and TypeScript: Part 1Haci Murat Yaman
 
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common LispLisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lispmasayukitakagi
 
Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?Koombea
 
Rubykaigi 2017-nishimotz-v6
Rubykaigi 2017-nishimotz-v6Rubykaigi 2017-nishimotz-v6
Rubykaigi 2017-nishimotz-v6Takuya Nishimoto
 

Tendances (20)

Why use Go for web development?
Why use Go for web development?Why use Go for web development?
Why use Go for web development?
 
Intoduction to React
Intoduction to ReactIntoduction to React
Intoduction to React
 
Custom angular libraries
Custom angular librariesCustom angular libraries
Custom angular libraries
 
Scaling up development of a modular code base
Scaling up development of a modular code baseScaling up development of a modular code base
Scaling up development of a modular code base
 
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
 
Crystal
CrystalCrystal
Crystal
 
Mono Repo
Mono RepoMono Repo
Mono Repo
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Why don't you Groovy?
Why don't you Groovy?Why don't you Groovy?
Why don't you Groovy?
 
Ruby in office time reboot
Ruby in office time rebootRuby in office time reboot
Ruby in office time reboot
 
The Saga of JavaScript and TypeScript: Part 1
The Saga of JavaScript and TypeScript: Part 1The Saga of JavaScript and TypeScript: Part 1
The Saga of JavaScript and TypeScript: Part 1
 
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common LispLisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
Lisp Meet Up #31, Clake: a GNU make-like build utility in Common Lisp
 
Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?Swift for back end: A new generation of full stack languages?
Swift for back end: A new generation of full stack languages?
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
ITT Flisol 2013
ITT Flisol 2013ITT Flisol 2013
ITT Flisol 2013
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Rubykaigi 2017-nishimotz-v6
Rubykaigi 2017-nishimotz-v6Rubykaigi 2017-nishimotz-v6
Rubykaigi 2017-nishimotz-v6
 

Similaire à javerosmx-2015-marzo-groovy-java8-comparison

Difference between java and c#
Difference between java and c#Difference between java and c#
Difference between java and c#TECOS
 
Groovy best pratices at EWAY
Groovy best pratices at EWAYGroovy best pratices at EWAY
Groovy best pratices at EWAYĐào Hiệp
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
 
Gwt overview & getting started
Gwt overview & getting startedGwt overview & getting started
Gwt overview & getting startedBinh Bui
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013Gavin Hogan
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...SQALab
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to GroovyKevin H.A. Tan
 
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)Alvaro Sanchez-Mariscal
 
Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)David Bosschaert
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gatesStrannik_2013
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumTechday7
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 

Similaire à javerosmx-2015-marzo-groovy-java8-comparison (20)

Difference between java and c#
Difference between java and c#Difference between java and c#
Difference between java and c#
 
Groovy best pratices at EWAY
Groovy best pratices at EWAYGroovy best pratices at EWAY
Groovy best pratices at EWAY
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
 
Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Java9to19Final.pptx
Java9to19Final.pptxJava9to19Final.pptx
Java9to19Final.pptx
 
Gwt overview & getting started
Gwt overview & getting startedGwt overview & getting started
Gwt overview & getting started
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
 
Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...Generalization in Auto-Testing. How we put what we had into new Technological...
Generalization in Auto-Testing. How we put what we had into new Technological...
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)OpenJDK Penrose Presentation (JavaOne 2012)
OpenJDK Penrose Presentation (JavaOne 2012)
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
 
java completed units.docx
java completed units.docxjava completed units.docx
java completed units.docx
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
java full 1 (Recovered).docx
java full 1 (Recovered).docxjava full 1 (Recovered).docx
java full 1 (Recovered).docx
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to Titanium
 
Java (1)
Java (1)Java (1)
Java (1)
 
Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
getting-your-groovy-on
getting-your-groovy-ongetting-your-groovy-on
getting-your-groovy-on
 

Plus de Domingo Suarez Torres

Cloud Native MX Meetup - Asegurando tu Cluster de Kubernetes
Cloud Native MX Meetup - Asegurando tu Cluster de KubernetesCloud Native MX Meetup - Asegurando tu Cluster de Kubernetes
Cloud Native MX Meetup - Asegurando tu Cluster de KubernetesDomingo Suarez Torres
 
Java Dev Day 2019 No kuberneteen por convivir
Java Dev Day 2019  No kuberneteen por convivirJava Dev Day 2019  No kuberneteen por convivir
Java Dev Day 2019 No kuberneteen por convivirDomingo Suarez Torres
 
Retos en la arquitectura de Microservicios
Retos en la arquitectura de MicroserviciosRetos en la arquitectura de Microservicios
Retos en la arquitectura de MicroserviciosDomingo Suarez Torres
 
DevFest Lima Corriendo cargas e trabajo seguras en GKE con Istio
DevFest Lima Corriendo cargas e trabajo seguras en GKE con IstioDevFest Lima Corriendo cargas e trabajo seguras en GKE con Istio
DevFest Lima Corriendo cargas e trabajo seguras en GKE con IstioDomingo Suarez Torres
 
Cloud Native Mexico - Introducción a Kubernetes
Cloud Native Mexico - Introducción a KubernetesCloud Native Mexico - Introducción a Kubernetes
Cloud Native Mexico - Introducción a KubernetesDomingo Suarez Torres
 
Meetup DigitalOcean Cloud Native architecture
Meetup DigitalOcean Cloud Native architectureMeetup DigitalOcean Cloud Native architecture
Meetup DigitalOcean Cloud Native architectureDomingo Suarez Torres
 
Cloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y Envoy
Cloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y EnvoyCloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y Envoy
Cloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y EnvoyDomingo Suarez Torres
 
Cloud Native Mexico Meetup enero 2018 Observability
Cloud Native Mexico Meetup enero 2018 ObservabilityCloud Native Mexico Meetup enero 2018 Observability
Cloud Native Mexico Meetup enero 2018 ObservabilityDomingo Suarez Torres
 
Orquestación de contenedores con Kubernetes SGNext
Orquestación de contenedores con Kubernetes SGNextOrquestación de contenedores con Kubernetes SGNext
Orquestación de contenedores con Kubernetes SGNextDomingo Suarez Torres
 
Webinar Arquitectura de Microservicios
Webinar Arquitectura de MicroserviciosWebinar Arquitectura de Microservicios
Webinar Arquitectura de MicroserviciosDomingo Suarez Torres
 

Plus de Domingo Suarez Torres (20)

Cloud Native MX Meetup - Asegurando tu Cluster de Kubernetes
Cloud Native MX Meetup - Asegurando tu Cluster de KubernetesCloud Native MX Meetup - Asegurando tu Cluster de Kubernetes
Cloud Native MX Meetup - Asegurando tu Cluster de Kubernetes
 
Java Dev Day 2019 No kuberneteen por convivir
Java Dev Day 2019  No kuberneteen por convivirJava Dev Day 2019  No kuberneteen por convivir
Java Dev Day 2019 No kuberneteen por convivir
 
Contenedores 101 Digital Ocean CDMX
Contenedores 101 Digital Ocean CDMXContenedores 101 Digital Ocean CDMX
Contenedores 101 Digital Ocean CDMX
 
Retos en la arquitectura de Microservicios
Retos en la arquitectura de MicroserviciosRetos en la arquitectura de Microservicios
Retos en la arquitectura de Microservicios
 
Java Cloud Native Hack Nights GDL
Java Cloud Native Hack Nights GDLJava Cloud Native Hack Nights GDL
Java Cloud Native Hack Nights GDL
 
meetup digital ocean kubernetes
meetup digital ocean kubernetesmeetup digital ocean kubernetes
meetup digital ocean kubernetes
 
Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
 
DevFest Lima Corriendo cargas e trabajo seguras en GKE con Istio
DevFest Lima Corriendo cargas e trabajo seguras en GKE con IstioDevFest Lima Corriendo cargas e trabajo seguras en GKE con Istio
DevFest Lima Corriendo cargas e trabajo seguras en GKE con Istio
 
Cloud Native Development in the JVM
Cloud Native Development in the JVMCloud Native Development in the JVM
Cloud Native Development in the JVM
 
Cloud Native Mexico - Introducción a Kubernetes
Cloud Native Mexico - Introducción a KubernetesCloud Native Mexico - Introducción a Kubernetes
Cloud Native Mexico - Introducción a Kubernetes
 
Meetup DigitalOcean Cloud Native architecture
Meetup DigitalOcean Cloud Native architectureMeetup DigitalOcean Cloud Native architecture
Meetup DigitalOcean Cloud Native architecture
 
Cloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y Envoy
Cloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y EnvoyCloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y Envoy
Cloud Native Mexico Meetup de Marzo 2018 Service Mesh con Istio y Envoy
 
Cloud Native Mexico Meetup enero 2018 Observability
Cloud Native Mexico Meetup enero 2018 ObservabilityCloud Native Mexico Meetup enero 2018 Observability
Cloud Native Mexico Meetup enero 2018 Observability
 
Cloud Native Mexico Presentacion
Cloud Native Mexico PresentacionCloud Native Mexico Presentacion
Cloud Native Mexico Presentacion
 
gRPC: Beyond REST
gRPC: Beyond RESTgRPC: Beyond REST
gRPC: Beyond REST
 
Devops Landscape
Devops LandscapeDevops Landscape
Devops Landscape
 
Orquestación de contenedores con Kubernetes SGNext
Orquestación de contenedores con Kubernetes SGNextOrquestación de contenedores con Kubernetes SGNext
Orquestación de contenedores con Kubernetes SGNext
 
JVM Reactive Programming
JVM Reactive ProgrammingJVM Reactive Programming
JVM Reactive Programming
 
SGNext Elasticsearch
SGNext ElasticsearchSGNext Elasticsearch
SGNext Elasticsearch
 
Webinar Arquitectura de Microservicios
Webinar Arquitectura de MicroserviciosWebinar Arquitectura de Microservicios
Webinar Arquitectura de Microservicios
 

Dernier

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 

Dernier (20)

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 

javerosmx-2015-marzo-groovy-java8-comparison

  • 1. Groovy & Java 8 A very simple comparison @ JaverosMX, Mexico City 30/Marzo/2015Domingo Suárez Torres (@domix)
  • 2. Agenda • Background • A little bit about Groovy • Why is important to upgrade to Java 8 • Comparison • Very small :’(
  • 3. Groovy, just a little • Optionally typed & dynamic language for the JVM • Static-typing and static compilation capabilities • Scripting capabilities, Domain-Specific Language authoring, runtime and compile-time meta-programming and functional programming
  • 4. Seamlessly and transparently integrates and interoperates with Java and any third-party libraries
  • 5.
  • 6. Java 8 matters • Java 7 EOL. April 2015 • Java 6 < go figure. • “Brand new” techniques, patterns, paradigms. Built in the language. • Very soon libraries and frameworks will adopt those improvements. • Enhancements • Nashorn • Invoke-dynamic • Java 8 arrived late to the party. Better late than never.
  • 7. Java 8 features • New Syntax • Stream API • Profiles • JavaFX • Date/Time API • Nashorn • Pack200 • JDBC • Concurrency • JAXP • Hotspot • Java Mission Control
  • 8. Java 8 syntax • Lambda expressions • Method references • static & default methods in interfaces • Repeating annotations • Annotation on types • Improved type inference • Method parameter reflection
  • 9.
  • 11. Feature similarities • Java 8 • Lambda expressions • Default methods • Optional types • Stream API • Method references • Groovy • Closures • Traits • Truth & null handling • GDK Collections • Method closures
  • 12. Code as data • Interfaces with one method (functional interface) • Single Abstract Method interfaces (SAM Interfaces) • Inner classes are annoying due verbosity. • Java 8 Lambda Expressions, Groovy Closures. • JVM functions became almost first-class citizens.
  • 14.
  • 16.
  • 17. Groovy Closures • Since 2003. • Is an open, anonymous, block of code that can take arguments. • Return a value and be assigned to a variable. • A closure may reference variables declared in its surrounding scope. • Can also contain free variables which are defined outside of its surrounding scope. In opposition to the formal definition of a closure.
  • 20. Closures behind scenes • Groovy creates an inner anonymous class • groovy.lang.Closure implements • Cloneable • Runnable • GroovyCallable • java.util.concurrent.Callable • Serializable
  • 21. Java 8 with Groovy
  • 23. Default methods • Non-abstract method implementations to interfaces by utilizing the default keyword • Also know as Extension Methods
  • 25. Default methods • Can be static methods • We can use them to implement multiple inheritance • Naming conflict¡
  • 26.
  • 28. Traits • The same idea as default methods in Java • Interface with method bodies • Can be stateful • Multiple inheritance
  • 29.
  • 30.
  • 32. java.util.Stream • Represents a sequence of elements on which one or more operations can be performed. • Stream operations are either intermediate or terminal. • While terminal operations return a result of a certain type, intermediate operations return the stream itself so you can chain multiple method calls in a row. • Streams are created on a source (Collection) • Stream operations can either be executed sequential or parallel.
  • 37. Groovy GDK • Groovy add lots of enhancements into the standard JDK • Groovy “injects” additional methods on the standard Java libraries • GDK adds syntactic sugar to Java APIs for better and easier usage.
  • 39. GDK and Java 8 • Some GDK facilities will be deprecated in favor of Stream • Stream is more efficient and performant • Groovy will focus in better integration with Java 8 enhancements
  • 41. java.util.Optional<T> • NPE is awkward. • A optional is a container object which may or may not contain a non-null value. • Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (return a default value if value not present) and ifPresent() (execute a block of code if the value is present).
  • 45. Groovy Truth • Everything that’s null, empty, zero-sized, equal to zero is false. Otherwise is true • Groovy Truth is quite simple: just implement a custom asBoolean() method.
  • 47. What to do? • IMO, Java 8 is a great release • Groovy is a madure alternative language for the JVM • My recommendation is to use both languages
  • 48. Java 8 highlights • Lambdas • Stream API • Nashorn. Avatar project
  • 49. Groovy Highlights • Traits • Metaprogramming • AST Transformations • DSL authoring • Android support • @TypeChecked @CompileStatic
  • 51. Picture credits • https://www.flickr.com/photos/eneas/3108310839/ • https://www.flickr.com/photos/eneas/6395912803/ • https://www.flickr.com/photos/80651083@N00/5641290457/ • https://www.flickr.com/photos/annuar_martinez/3282050044/ • https://www.flickr.com/photos/luismontemayor/2550701324/ • https://www.flickr.com/photos/guseher/2393646953/ • https://www.flickr.com/photos/annuar_martinez/2342099774/ • https://www.flickr.com/photos/luismontemayor/4306210583/ • https://www.flickr.com/photos/lastingimages/12262034856/ • https://www.flickr.com/photos/atejada/14169147706/ • https://www.flickr.com/photos/luismontemayor/3018556662/ • https://www.flickr.com/photos/eneas/2290156408/ • https://www.flickr.com/photos/122274109@N03/16154663524/ • https://www.flickr.com/photos/krynowekeine/2755263171/ • https://www.flickr.com/photos/nino_ary/2901716788/ • https://www.flickr.com/photos/eneas/5279761/ • https://www.flickr.com/photos/lastingimages/12373124983/ • https://www.flickr.com/photos/rmgg-photos/8503188042/ • https://www.flickr.com/photos/luajr/15127961825/ • https://www.flickr.com/photos/gtercero/8740734623/ • https://www.flickr.com/photos/egmzcp15/5237066174/ • https://www.flickr.com/photos/rouleau/109405487/ • https://www.flickr.com/photos/xavier333/2257501542/ • https://www.flickr.com/photos/pvcg/3087911579/ • https://www.flickr.com/photos/notocajrs/12785034584/ • https://www.flickr.com/photos/nahual_neo/8005123271/ • https://www.flickr.com/photos/chicotown/3189442699/ • https://www.flickr.com/photos/kootenayhulio/5497898774/ • https://www.flickr.com/photos/maybemaq/16579363326/ • https://www.flickr.com/photos/luajr/15484454837/
  • 52. Picture credits • https://www.flickr.com/photos/nahual_neo/4290121443/ • https://www.flickr.com/photos/70120970@N08/8493760801/ • https://www.flickr.com/photos/gustavothomastheatre/15823470423/ • https://www.flickr.com/photos/graficris_lgs/15543907818/ • https://www.flickr.com/photos/gustavothomastheatre/15708898754/ • https://www.flickr.com/photos/john_colby/8430729849/ • https://www.flickr.com/photos/egmzcp15/4144937818/ • https://www.flickr.com/photos/10066932@N03/2552609658/ • https://www.flickr.com/photos/bdebaca/2987372965/ • https://www.flickr.com/photos/beco/23806123