Java.il - Confessions of a java developer that fell in love with the groovy language

47
Confessions of a Java developer that fell in love with the Groovy language Victor Trakhtenberg [email protected] @victortr75

Transcript of Java.il - Confessions of a java developer that fell in love with the groovy language

Page 1: Java.il - Confessions of a java developer that fell in love with the groovy language

Confessions  of  a    Java  developer    

that  fell  in  love  with  the  Groovy  language  

Victor  Trakhtenberg    

   

[email protected]              @victortr75            

Page 2: Java.il - Confessions of a java developer that fell in love with the groovy language

Personal  

My  name  is  Victor  

Page 3: Java.il - Confessions of a java developer that fell in love with the groovy language

Personal  

Java.IL  community  co-­‐founder  

h=p://www.meetup.com/JavaIL/  

Page 4: Java.il - Confessions of a java developer that fell in love with the groovy language

Personal  

Full  Stack  Engineer  @    

h@p://commercesciences.com/jobs  

Page 5: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 6: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 7: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 8: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 9: Java.il - Confessions of a java developer that fell in love with the groovy language

It  is  NOT  an  introducFon  to  Groovy  

It  is  NOT  “why  you  should  not  use  Java”  

It  is  NOT  “why  you  must    use    

Groovy”  

Page 10: Java.il - Confessions of a java developer that fell in love with the groovy language

It  is  “why  every  Java  developer    

SHOULD  KNOW    Groovy”  

Page 11: Java.il - Confessions of a java developer that fell in love with the groovy language

Groovy  is  very  easy  to  enter  into  for  Java  developers,  

since…  

Java  code  is  Groovy  code  

Page 12: Java.il - Confessions of a java developer that fell in love with the groovy language

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…  

Page 13: Java.il - Confessions of a java developer that fell in love with the groovy language

Groovy  is  more  than  just  a  set  of  features,  

it  is  more  than  a  be=er  Java  

Page 14: Java.il - Confessions of a java developer that fell in love with the groovy language

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…  

Page 15: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 16: Java.il - Confessions of a java developer that fell in love with the groovy language

Using  Groovy  

Raise  your  hands  

Using  Java  

Using  Ruby,Python,  Scala  etc.  

Page 17: Java.il - Confessions of a java developer that fell in love with the groovy language

Prelude  -­‐  REPL  

Page 18: Java.il - Confessions of a java developer that fell in love with the groovy language

Groovy  CollecFons  

Page 19: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 20: Java.il - Confessions of a java developer that fell in love with the groovy language

Map  with  default  

Page 21: Java.il - Confessions of a java developer that fell in love with the groovy language

h=p://groovy-­‐the-­‐superb-­‐homeless.mally.pl/  

Page 22: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 23: Java.il - Confessions of a java developer that fell in love with the groovy language

Using  Groovy  in  a  running  Java  project  

Our  setup:  Java  Play!  Framework  project  

Choose  one  concern  to  use  Groovy  

Our  choice:  JSON  manipulaFons  

Page 24: Java.il - Confessions of a java developer that fell in love with the groovy language

Parse  JSON  

Page 25: Java.il - Confessions of a java developer that fell in love with the groovy language

Build  JSON  

Page 26: Java.il - Confessions of a java developer that fell in love with the groovy language

Case  Study:  Campaign  ConfiguraFon    Management  

Page 27: Java.il - Confessions of a java developer that fell in love with the groovy language

The  Java  interface  and    the  Groovy  implementaFon  

Page 28: Java.il - Confessions of a java developer that fell in love with the groovy language

Java-­‐to-­‐Groovy  Bridge  

Page 29: Java.il - Confessions of a java developer that fell in love with the groovy language

Fetch  campaign  type  

Page 30: Java.il - Confessions of a java developer that fell in love with the groovy language

Is  it  a  ‘coupon’  campaign  

Page 31: Java.il - Confessions of a java developer that fell in love with the groovy language

Is  it  a  ‘coupon’  campaign  

Page 32: Java.il - Confessions of a java developer that fell in love with the groovy language

Is  it  a  ‘coupon’  campaign  

Page 33: Java.il - Confessions of a java developer that fell in love with the groovy language

Integrate  with  Salesforce    

Page 34: Java.il - Confessions of a java developer that fell in love with the groovy language

Update  account  at  Salesforce  

Page 35: Java.il - Confessions of a java developer that fell in love with the groovy language

Integrate  with  Salesforce  -­‐  AuthenFcate  

Page 36: Java.il - Confessions of a java developer that fell in love with the groovy language

URIBuilder  

Page 37: Java.il - Confessions of a java developer that fell in love with the groovy language

URIBuilder  -­‐  Java  

Page 38: Java.il - Confessions of a java developer that fell in love with the groovy language

Challenges  

•  Java  <-­‐>  Groovy  bridge  – The  need  for  the  Java  interface  

•  IDE  support  – Browsing  Java  code  –  Groovy  code  

•  Long  stack  traces    –   challenging  debugging  

•  Coding  convenFons  

Page 39: Java.il - Confessions of a java developer that fell in love with the groovy language

Use  Groovy  for  non-­‐producFon  

Page 40: Java.il - Confessions of a java developer that fell in love with the groovy language

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  

Page 41: Java.il - Confessions of a java developer that fell in love with the groovy language

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  •  …  

Page 42: Java.il - Confessions of a java developer that fell in love with the groovy language

h=p://jaxenter.com/groovy-­‐is-­‐the-­‐swin-­‐alternaFve-­‐for-­‐android-­‐107846.html  

Page 43: Java.il - Confessions of a java developer that fell in love with the groovy language

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  

Page 44: Java.il - Confessions of a java developer that fell in love with the groovy language

MrHaki  –  Groovy  Goodness  

h=p://mrhaki.blogspot.co.il/2009/09/groovy-­‐goodness-­‐padding-­‐strings.html  

Page 45: Java.il - Confessions of a java developer that fell in love with the groovy language

Groovy  Challenge!    

Save  the  date:  31-­‐May  

h=p://www.meetup.com/WeCode-­‐IL/  

Page 46: Java.il - Confessions of a java developer that fell in love with the groovy language
Page 47: Java.il - Confessions of a java developer that fell in love with the groovy language

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