confessions of a java developer that fell in love with the groovy language

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

Upload: victor-trakhtenberg

Post on 16-Jul-2015

541 views

Category:

Technology


3 download

TRANSCRIPT

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

http://www.meetup.com/JavaIL/

Personal

Full Stack Engineer @

http://commercesciences.com/jobs

It is NOT an introduction 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

MUST KNOW Groovy”

Groovy is very easy to enter into for Java developers,

since…

Java code is Groovy code

Groovy Features

• Strings

• Collections

• Date

• Parsing and producing JSON

• Working with a DB

• Processing XML

• Template engines

• Builders

• Grapes

• Traits

• Processing configuration

• HTTPBuilder

• and many more…

Groovy is more than just a set of features,

it is more than a better Java

There are new concepts for Java developers

• Dynamic language• with optional static-typing and static-

compilation• Closures• Functional programming• Meta-programming• Mixins• DSLs • and more…

Using Groovy

Raise your hands

Using Java

Using Ruby,Python, Scala etc.

Prelude - REPL

Groovy Collections

Map with default

http://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 manipulations

Parse JSON

Build JSON

Case Study: Campaign Configuration Management

The Java interface and the Groovy implementation

Java-to-Groovy Bridge

Fetch campaign type

Is it a ‘coupon’ campaign

Is it a ‘coupon’ campaign

Is it a ‘coupon’ campaign

http://groovy.codehaus.org/modules/http-builder/home.html

Integrate with Salesforce

Update account at Salesforce

Integrate with Salesforce - Authenticate

URIBuilder

URIBuilder - Java

Challenges

• IDE support

– Browsing Java code – Groovy code

• Long stack traces

– challenging debugging

• Coding conventions

Use Groovy for non-production

Groovy in light of Java8

• There is still a gap between Java 8 and Groovy

• There is a synergy between Groovy and Java 8

http://www.slideshare.net/SpringCentral/groovy-in-thelightofjava8http://www.javacodegeeks.com/2014/06/java-8-lambdas-vs-groovy-closures-compactness-grouping-and-summing.html

http://jaxenter.com/groovy-is-the-swift-alternative-for-android-107846.html

Groovy resources• http://groovy-lang.org/• http://glaforge.appspot.com/category/Groovy%20Weekly• http://www.mrhaki.com/• https://plus.google.com/communities/105160926044623621768• http://www.mscharhag.com/2015/02/creating-android-apps-with-

groovy.html• http://groovy.codehaus.org/modules/http-builder/doc/uribuilder.html• http://www.drdobbs.com/jvm/why-build-your-java-projects-with-

gradle/240168608?pgno=3• http://www.infoq.com/presentations/groovy-test-java-spock• http://www.infoq.com/presentations/testing-spock-geb• http://melix.github.io/blog/2015/02/who-is-groovy.html• http://groovy-the-superb-homeless.mally.pl/#/• http://www.eweek.com/developer/groovy-language-proposed-as-

apache-incubator-project.html• https://github.com/victorgit/GroovyPresentation

MrHaki – Groovy Goodness

http://mrhaki.blogspot.co.il/2009/09/groovy-goodness-padding-strings.html

Images sources

• http://www.clevercuties.com/myimages/products/Computers/IHEARTPROGRAMMING.jpg• http://blogs.perceptionsystem.com/wp-content/uploads/2013/12/Happy-Customer.jpg• http://lifepalette.com/wp-content/uploads/2015/01/Productivity.jpg• http://www.checkaction.com/blog/wp-content/uploads/2014/01/startup-employee-productivity-tips-675x320.jpg• http://www.akifarslan.com.tr/wp-content/uploads/2013/10/java.jpg• http://cdn.makeuseof.com/wp-content/uploads/2012/03/jvm.png?84ec63• http://cdn.slidesharecdn.com/ss_thumbnails/ecosystem-120717081103-phpapp01-thumbnail-

4.jpg?cb=1342530724• http://www.army-armee.forces.gc.ca/assets/ARMY_Internet/images/ceremonial-guard/index-main.jpg• http://www.local-guru.net/img/guru/have_fun.png• http://blog.xo.com/wp-content/uploads/2014/03/pic-raised-hands-550x300.png• https://pbs.twimg.com/media/BVDKBfUCIAAWKw9.jpg• http://www.nscsd.org/webpages/jenkondrk/imageGallery/Clip%20art/raise%20hand.gif• http://ubik.cc/MAOW-Firenze-09/images/repl-loop.png• http://hirportal.sikerado.hu/images/kep/201110/belyeg.jpg• http://www.slideshare.net/SpringCentral/groovy-in-thelightofjava8• http://blog.pivotal.io/pivotal/news-2/groovy-2-4-and-grails-3-0-to-be-last-major-releases-under-pivotal-

sponsorship• http://therealdanvega.com/blog/2015/01/20/pivotal-drops-groovy-grails-sponsorship• http://grails.io/post/108534902333/the-future-of-groovy-grails-sponsorship• http://groovy.mn/static/hh97hMrFEv8Xc9j1zvR9winGH86xmHGbiZNKFTORWYl.jpg