why don't you groovy?

17
Why Don't you Groovy? Engineering Communities 05 May 2016 Orest Ivasiv Software engineer, Softserve

Upload: orest-ivasiv

Post on 15-Apr-2017

58 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Why don't you Groovy?

Why Don't you Groovy?Engineering Communities

05 May 2016

Orest IvasivSoftware engineer, Softserve

Page 2: Why don't you Groovy?

Audience

Java developers

No experience in Groovy

Page 3: Why don't you Groovy?

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?

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?

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?

Scripts vs Tools

Page 7: Why don't you Groovy?

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?

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?

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?

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?

Language features

Page 12: Why don't you Groovy?

Language features

List

Map

GString

GDK

MOP

Builders

Page 13: Why don't you Groovy?

Groovy Samples

Page 14: Why don't you Groovy?

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?

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?

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?

Thank you

05 May 2016Tags: groovy (#ZgotmplZ)

Orest IvasivSoftware engineer, Softserve@halyph (http://twitter.com/halyph)