why don't you groovy?
TRANSCRIPT
![Page 1: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/1.jpg)
Why Don't you Groovy?Engineering Communities
05 May 2016
Orest IvasivSoftware engineer, Softserve
![Page 2: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/2.jpg)
Audience
Java developers
No experience in Groovy
![Page 3: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/3.jpg)
Disclaimer
We will not talk about Groovy language in details
It's not a tutorial
We are not Groovy haters/lovers. We are pragmatic devs
Groovy is not a panacea, Groovy is a hammer
Hipsters are not Groovy (it's 2016)
![Page 4: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/4.jpg)
Problems and Tasks
Java devs should not write scripts in Java
Bash, Python, Ruby, etc.
How to re-use existence Java knowledge in automation tasks
How to choose the right scripting language
How to automate on Windows, Linux and OSX
![Page 5: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/5.jpg)
Why Java is bad for scripting and automation?
Tedious File and Network processing
Tedious collection processing
Tedious XML/JSON processing
Verbose type declaration
Limited DSL support
Painful object construction code
Just too verbose for small tasks
Slow Edit-Compile-Run loop
![Page 6: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/6.jpg)
Scripts vs Tools
![Page 7: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/7.jpg)
Scripts
Run on all major OSs
Easy to distribute
Easy to read and maintain
Reasonably small
Quick Edit-Run cycle
Performance is not important
E.g.
- Bash, Ruby, Python, Node.js, Groovy - Tcl, Lua
![Page 8: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/8.jpg)
Tools
No sources
"Fat" binary
Popular or/and minimal runtime
No runtime - single binary
Very easy to distribute
Low maintenance cost
E.g.
- Java/JVM, Go - C/C++, Python, Node.js
![Page 9: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/9.jpg)
Groovy
JVM language
Java, Scala, Clojure, Groovy, Kotlin
Superb interoperability with Java
Syntax is very similar to Java
All Java libraries can be used in Groovy
Almost all Java code is Groovy code
Groovy language is full of modern features
DSL
![Page 10: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/10.jpg)
Groovy is compiled Language
Groovy is a dynamic language Dynamic != interpreted Interpreted == a runtime interprets an AST Groovy compiles down to JVM bytecode
![Page 11: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/11.jpg)
Language features
![Page 12: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/12.jpg)
Language features
List
Map
GString
GDK
MOP
Builders
![Page 13: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/13.jpg)
Groovy Samples
![Page 14: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/14.jpg)
Launching a Jetty server to serve Groovy templates
@Grapes([ @Grab(group='org.eclipse.jetty.aggregate', module='jetty-server', version='8.1.7.v20120910'), @Grab(group='org.eclipse.jetty.aggregate', module='jetty-servlet', version='8.1.7.v20120910'), @Grab(group='javax.servlet', module='javax.servlet-api', version='3.0.1')]) import org.eclipse.jetty.server.Server import org.eclipse.jetty.servlet.* import groovy.servlet.* def runServer(duration) { def server = new Server(8080) def context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); context.resourceBase = "." context.addServlet(TemplateServlet, "*.gsp") server.start() sleep duration server.stop() } runServer(10000)
![Page 15: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/15.jpg)
What's ugly in Groovy
JVM and Groovy script start time is slow
Limited OS-level scripting (see Python, Ruby)
Groovy is another language. It’s not Java (thanks cap)
Groovy is not well accepted in other communities
Not convenient to use Groovy without IDE
![Page 16: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/16.jpg)
References
Who is Groovy? by Cédric Champeau – history and people behind Groovy language(http://melix.github.io/blog/2015/02/who-is-groovy.html)
Blog about Groovy, Gradle and Grails (http://mrhaki.blogspot.com)
http://groovy-lang.org/ (http://groovy-lang.org/)
Groovy on the Shell (https://www.youtube.com/watch?v=1ogwSsl6EGQ)
Curated list of awesome groovy libraries, frameworks and resourcesy (https://github.com/kdabir/awesome-
groovy)
![Page 17: Why don't you Groovy?](https://reader030.vdocument.in/reader030/viewer/2022021422/587aad231a28abed218b598d/html5/thumbnails/17.jpg)
Thank you
05 May 2016Tags: groovy (#ZgotmplZ)
Orest IvasivSoftware engineer, Softserve@halyph (http://twitter.com/halyph)