Upload
victor-trakhtenberg
View
72
Download
1
Tags:
Embed Size (px)
Citation preview
Confessions of a Java developer
that fell in love with the Groovy language
Victor Trakhtenberg
[email protected] @victortr75
Personal
My name is Victor
Personal
Java.IL community co-‐founder
h=p://www.meetup.com/JavaIL/
Personal
Full Stack Engineer @
h@p://commercesciences.com/jobs
It is NOT an introducFon to Groovy
It is NOT “why you should not use Java”
It is NOT “why you must use
Groovy”
It is “why every Java developer
SHOULD KNOW Groovy”
Groovy is very easy to enter into for Java developers,
since…
Java code is Groovy code
Groovy Features
• Strings • CollecFons • Date • Parsing and producing JSON
• Working with a DB • Processing XML • Template engines
• Builders • Grapes • Traits • Processing configuraFon
• HTTPBuilder • and many more…
Groovy is more than just a set of features,
it is more than a be=er Java
There are new concepts for Java developers
• Dynamic language • with opFonal staFc-‐typing and staFc-‐compilaFon
• Closures • FuncFonal programming • Meta-‐programming • Traits • DSLs • and more…
Using Groovy
Raise your hands
Using Java
Using Ruby,Python, Scala etc.
Prelude -‐ REPL
Groovy CollecFons
Map with default
h=p://groovy-‐the-‐superb-‐homeless.mally.pl/
Using Groovy in a running Java project
Our setup: Java Play! Framework project
Choose one concern to use Groovy
Our choice: JSON manipulaFons
Parse JSON
Build JSON
Case Study: Campaign ConfiguraFon Management
The Java interface and the Groovy implementaFon
Java-‐to-‐Groovy Bridge
Fetch campaign type
Is it a ‘coupon’ campaign
Is it a ‘coupon’ campaign
Is it a ‘coupon’ campaign
Integrate with Salesforce
Update account at Salesforce
Integrate with Salesforce -‐ AuthenFcate
URIBuilder
URIBuilder -‐ Java
Challenges
• Java <-‐> Groovy bridge – The need for the Java interface
• IDE support – Browsing Java code – Groovy code
• Long stack traces – challenging debugging
• Coding convenFons
Use Groovy for non-‐producFon
Groovy in light of Java8
• There is sFll a gap between Java 8 and Groovy • There is a synergy between Groovy and Java 8
h=p://www.slideshare.net/SpringCentral/groovy-‐in-‐thelightoaava8 h=p://www.javacodegeeks.com/2014/06/java-‐8-‐lambdas-‐vs-‐groovy-‐closures-‐compactness-‐grouping-‐and-‐summing.html
Groovy in light of Java8 • Groovy syntax is more compact • JDK classes enhancements (String, URL, File etc.) • Operator overloading • MemoizaFon + trampoliningRegular expressions • SQL handling • Coercion of types to Boolean • JSN + XML parsing and producing • Traits • AST transformaFons • DSL • …
h=p://jaxenter.com/groovy-‐is-‐the-‐swin-‐alternaFve-‐for-‐android-‐107846.html
Groovy resources • h=p://groovy-‐lang.org/ • h=p://glaforge.appspot.com/category/Groovy%20Weekly • h=p://www.mrhaki.com/ • h=ps://plus.google.com/communiFes/105160926044623621768 • h=p://www.mscharhag.com/2015/02/creaFng-‐android-‐apps-‐with-‐
groovy.html • h=p://groovy.codehaus.org/modules/h=p-‐builder/doc/uribuilder.html • h=p://www.drdobbs.com/jvm/why-‐build-‐your-‐java-‐projects-‐with-‐
gradle/240168608?pgno=3 • h=p://www.infoq.com/presentaFons/groovy-‐test-‐java-‐spock • h=p://www.infoq.com/presentaFons/tesFng-‐spock-‐geb • h=p://melix.github.io/blog/2015/02/who-‐is-‐groovy.html • h=p://groovy-‐the-‐superb-‐homeless.mally.pl/#/ • h=ps://github.com/victorgit/GroovyPresentaFon
MrHaki – Groovy Goodness
h=p://mrhaki.blogspot.co.il/2009/09/groovy-‐goodness-‐padding-‐strings.html
Groovy Challenge!
Save the date: 31-‐May
h=p://www.meetup.com/WeCode-‐IL/
Images sources • h=p://www.clevercuFes.com/myimages/products/Computers/IHEARTPROGRAMMING.jpg • h=p://blogs.percepFonsystem.com/wp-‐content/uploads/2013/12/Happy-‐Customer.jpg • h=p://lifepale=e.com/wp-‐content/uploads/2015/01/ProducFvity.jpg • h=p://www.checkacFon.com/blog/wp-‐content/uploads/2014/01/startup-‐employee-‐producFvity-‐Fps-‐675x320.jpg • h=p://www.akifarslan.com.tr/wp-‐content/uploads/2013/10/java.jpg • h=p://cdn.makeuseof.com/wp-‐content/uploads/2012/03/jvm.png?84ec63 • h=p://cdn.slidesharecdn.com/ss_thumbnails/ecosystem-‐120717081103-‐phpapp01-‐thumbnail-‐4.jpg?cb=1342530724 • h=p://www.army-‐armee.forces.gc.ca/assets/ARMY_Internet/images/ceremonial-‐guard/index-‐main.jpg • h=p://www.local-‐guru.net/img/guru/have_fun.png • h=p://blog.xo.com/wp-‐content/uploads/2014/03/pic-‐raised-‐hands-‐550x300.png • h=ps://pbs.twimg.com/media/BVDKBfUCIAAWKw9.jpg • h=p://www.nscsd.org/webpages/jenkondrk/imageGallery/Clip%20art/raise%20hand.gif • h=p://ubik.cc/MAOW-‐Firenze-‐09/images/repl-‐loop.png • h=p://hirportal.sikerado.hu/images/kep/201110/belyeg.jpg • h=p://www.slideshare.net/SpringCentral/groovy-‐in-‐thelightoaava8 • h=p://blog.cacoethes.co.uk/groovyandgrails/groovy-‐in-‐light-‐of-‐java-‐8 • h=p://www.infoq.com/arFcles/groovy-‐to-‐Java-‐8 • h=ps://tedvinke.wordpress.com/2014/06/20/java-‐8-‐lambdas-‐vs-‐groovy-‐closures-‐compactness-‐grouping-‐and-‐summing/ • h=p://groovy.mn/staFc/hh97hMrFEv8Xc9j1zvR9winGH86xmHGbiZNKFTORWYl.jpg