SlideShare uma empresa Scribd logo
1 de 52
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

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

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

Mais 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
 

Mais 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
 

Último

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Último (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

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