Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Why Groovy Gr8Conf 2018

Why Groovy Gr8Conf 2018

Groovy has been around for a long time, but over the last several years, Groovy has changed a lot. Some of the articles, blog posts, and talks published about early versions of Groovy are just no longer true. By the end of this session, you’ll be able to tell some of the best Groovy truth from fiction and leave with some solid arguments for your boss and others as to why Groovy is such an awesome, productive, and readable alternative language for the JVM.

We'll start with some of the community’s favorite features like special operators, optional typing, metaprogramming, and dynamic vs. static compilation. We’ll also explore popular libraries and frameworks where knowing Groovy would be helpful such as Gradle build files, Elasticsearch, Jenkins, and Apache Spark. The session concludes with ways to learn more and how to contribute to making Groovy even more groovy.

------
Jennifer “Jenn” Strater is a Senior Engineer at Zenjob Gmbh in Berlin, Germany where we revolutionize the way students work. She was formerly a co-founder of GR8Ladies and is now part of the board of GR8DI, the Apache Groovy Diversity Initiative. She has also organized GR8Workshops for developers interested in an overview and crash course in Groovy technologies and presented on several Groovy topics at events such as the Grace Hopper Celebration of Women in Computing, Greach, GR8Conf EU, GR8Conf US, Devoxx Belgium, JFokus, and Spring One Platform.

jlstrater

May 31, 2018
Tweet

More Decks by jlstrater

Other Decks in Technology

Transcript

  1. Why use #groovylang? How to
    convince your boss and others
    Jenn Strater
    @codeJENNerator
    @zenjobcom

    View Slide

  2. @codeJENNerator
    Note For Those Viewing
    Slides Online
    • Bulleted text like this indicates the key points
    mentioned on a previous slide. They may not have
    been included in the official presentation.
    • Not every slide was in the presentation. There is
    more content then time so some are skipped at
    some conferences.
    • If this view does not support links, the links will work
    in the pdf. Click the ‘download pdf’ button on the
    right.

    View Slide

  3. @codeJENNerator
    Follow Along
    https://speakerdeck.com/jlstrater/why-groovy-gr8conf-2018

    View Slide

  4. Follow Along
    https://speakerdeck.com/jlstrater/test-driven-docs-springone-2017
    https://github.com/jlstrater/groovy-spring-boot-restdocs-example
    https://github.com/ratpack/example-books
    https://github.com/jlstrater/spring-restdocs-public-api-example

    View Slide

  5. Follow Along
    https://speakerdeck.com/jlstrater/test-driven-docs-springone-2017
    https://github.com/jlstrater/groovy-spring-boot-restdocs-example
    https://github.com/ratpack/example-books
    https://github.com/jlstrater/spring-restdocs-public-api-example

    View Slide

  6. @codeJENNerator
    About Me
    - Working at Zenjob.

    - Groovy (mostly Grails) user since 2013.

    - Before moving to Berlin, I spent a year in Copenhagen.

    - Before that, I was senior consultant at Object Partners, Inc. in
    Minneapolis, MN, USA.

    - Co-founder of Gr8Ladies (deprecated)

    - Passionate about bring new people into the Groovy community through
    free introductory workshops called Gr8Workshops and supporting
    underrepresented minorities and their careers in tech.

    View Slide

  7. @codeJENNerator
    Audience Background

    View Slide

  8. @codeJENNerator
    Audience Background
    • Groovy
    • Everyday user
    • Side project user
    • New to Groovy

    View Slide

  9. @codeJENNerator
    Audience Background
    • Groovy
    • Everyday user
    • Side project user
    • New to Groovy

    View Slide

  10. @codeJENNerator
    Audience Background
    • Groovy
    • Everyday user
    • Side project user
    • New to Groovy
    • Frameworks / Tools
    • Grails
    • Spock
    • Gradle
    • Griffon
    • Jenkins

    View Slide

  11. @codeJENNerator
    –Andres Almiray @aalmiary
    “Groovy developers don’t seem to care about
    hype, they simply get the job done.”

    View Slide

  12. @codeJENNerator
    Outline
    • Why use Groovy?
    • Truth or Myth?
    • Ways to Start Using Groovy Today!

    View Slide

  13. View Slide

  14. View Slide

  15. @codeJENNerator
    Features

    View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. View Slide

  20. View Slide

  21. View Slide

  22. View Slide

  23. @codeJENNerator
    Ecosystem

    View Slide

  24. View Slide

  25. View Slide

  26. View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. @codeJENNerator
    Community

    View Slide

  31. View Slide

  32. View Slide

  33. @codeJENNerator
    http://bit.ly/groovy-word-cloud

    View Slide

  34. @codeJENNerator
    Groovy is awesome
    because…
    • Great features
    • Thriving ecosystem
    • Friendly community

    View Slide

  35. @codeJENNerator

    View Slide

  36. @codeJENNerator
    Truth
    or Myth?

    View Slide

  37. @codeJENNerator
    • After spending some time at Java User Groups,
    Conferences, and reading lots of stuff online, I
    realized that there are a lot of things people get
    wrong about Groovy or that just aren’t true in the
    most recent versions.
    • All of these assumptions are things are related to
    conversations I’ve had with real people at some
    point in my career.

    View Slide

  38. @codeJENNerator
    Groovy is the same
    thing as Grails

    View Slide

  39. View Slide

  40. @codeJENNerator
    • Groovy is a language and can be used
    independently or in many different frameworks
    including:
    • Grails
    • Griffon
    • Gaelyk
    • Spock
    • Ratpack
    • Vertx
    • And many more!

    View Slide

  41. @codeJENNerator
    Groovy is just a
    scripting language

    View Slide

  42. @codeJENNerator
    Yes and No

    View Slide

  43. @codeJENNerator
    • Groovy CAN BE used for scripting, but it’s NOT
    ONLY a scripting language. It can also be used in
    OOP and functional projects too.

    View Slide

  44. @codeJENNerator
    James Strachan, the
    creator of Groovy, has left
    the community

    View Slide

  45. @codeJENNerator
    James Strachan, the
    creator of Groovy, has left
    the community

    View Slide

  46. View Slide

  47. @codeJENNerator
    • 2009 http://macstrac.blogspot.de/2009/04/scala-as-long-
    term-replacement-for.html
    • 2017 https://medium.com/@jstrachan/fwiw-i-still-use-
    groovy-most-days-thanks-to-jenkins-pipelines-along-with-
    java-typescript-ef5f8b05acbe

    View Slide

  48. @codeJENNerator
    4. Groovy’s dynamic
    nature can mean more
    runtime errors

    View Slide

  49. @codeJENNerator

    View Slide

  50. @codeJENNerator
    But…

    View Slide

  51. @codeJENNerator

    View Slide

  52. @codeJENNerator
    • We protect against runtime errors with good
    practices like static analysis tools (think
    Codenarc), code reviews, writing comprehensive
    tests, and learning about common pitfalls and
    mistakes made in Groovy (like reading blogs and
    going to conferences)
    • Moving execution of code to runtime isn’t always
    bad, sometimes adding null-safes can protect
    against NPEs.

    View Slide

  53. From Iván Lopez’s “ I've seen Grails code you wouldn't believe…” at Greach 2018 Slides

    View Slide

  54. @codeJENNerator
    Groovy is a dynamically
    typed language

    View Slide

  55. @codeJENNerator
    Not really

    View Slide

  56. @codeJENNerator
    • Groovy is OPTIONALLY typed. Def can be used when a type
    is flexible, but unlike some other languages, declaring def x =
    3 followed by x = ‘hello’ is totally valid Groovy.
    • Also, using static compilation (vs the default dynamic
    compilation) makes a difference in what behaviors are
    allowed.
    • Groovy is called dynamic language not because of typing but
    because of the dynamic features including runtime
    metaprogramming.
    • For a really good explanation of the Groovy type system, read
    Groovy in Action 2nd Edition!

    View Slide

  57. @codeJENNerator
    Groovy is not suitable
    for production apps

    View Slide

  58. @codeJENNerator
    Not really

    View Slide

  59. @codeJENNerator

    View Slide

  60. @codeJENNerator
    Groovy is slow

    View Slide

  61. @codeJENNerator

    View Slide

  62. @codeJENNerator
    It depends!

    View Slide

  63. @codeJENNerator
    • It’s true that Groovy is slower than optimal Java,
    but not by as much as most people think.

    View Slide

  64. @codeJENNerator
    • It mainly depends on what you write. For example,
    some improperly used looping methods may be
    slower than the Java counterpart.
    • Compilation also matters. Statically compiled Groovy
    code can run almost as fast as well-written Java
    code. However, dynamic Groovy isn’t that much
    slower (if written with performance in mind).
    • Consider reading https://www.linkedin.com/pulse/
    how-make-groovy-fast-java-david-e-jones/ for more
    info.

    View Slide

  65. @codeJENNerator
    8. Gradle is switching to
    Kotlin because Groovy
    sucks.

    View Slide

  66. View Slide

  67. @codeJENNerator
    • Gradle needed some major reworking. Not because of Groovy itself but
    because of how they implemented the DSL (hindsight is always 20/20!)
    • Kotlin solves issues that many end users (especially Android devs) have with
    Gradle including poor IntelliJ support and the fact that many people don’t
    know Groovy. I’ve seen so many people use it without really knowing the best
    practices resulting in horrible builds. That’s not really the fault of Groovy or
    Gradle, but .
    • Gradle could have been reworked to support Groovy better, but for now,
    Kotlin makes more sense.
    • Also, Groovy support is not going away! Kotlin is just being added (with
    maybe some extra enhancements).
    • Mostly from my own experience and http://melix.github.io/blog/2016/05/
    gradle-kotlin.html

    View Slide

  68. @codeJENNerator
    You can write a project
    entirely in statically
    compiled Groovy

    View Slide

  69. View Slide

  70. @codeJENNerator
    • If you find yourself forgetting to add
    @CompileStatic at the top of every file in your
    groovy code, you can set compiler options using
    Gradle and it will apply static compilation to every
    file in your source directory.
    • https://stackoverflow.com/a/30307025/2250125

    View Slide

  71. @codeJENNerator
    Grails is Rails for the
    JVM

    View Slide

  72. View Slide

  73. @codeJENNerator
    • Although Grails originally started as a Rails like
    MVC framework for the JVM, it has since very
    much diverged from Ruby on Rails. Grails is not
    just for monoliths but the profile system can be
    used for many different types of applications.
    Grails 3.0 is also heavy reliant on Spring Boot and
    goes even further in that direction.

    View Slide

  74. @codeJENNerator
    Groovy is dead

    View Slide

  75. @codeJENNerator

    View Slide

  76. @codeJENNerator
    Groovy Downloads in Thousands
    0
    1500
    3000
    4500
    6000
    January 2012 July 2012 January 2013 July 2013 January 2014 July 2014 January 2015 July 2015 January 2016 July 2016 January 2017 July 2017
    Codehaus
    Bintray
    Maven Central

    View Slide

  77. @codeJENNerator
    Groovy Downloads in Thousands
    0
    1500
    3000
    4500
    6000
    January 2012 July 2012 January 2013 July 2013 January 2014 July 2014 January 2015 July 2015 January 2016 July 2016 January 2017 July 2017
    Codehaus
    Bintray
    Maven Central
    End of Pivotal Support

    View Slide

  78. @codeJENNerator
    Groovy Downloads in Thousands
    0
    1500
    3000
    4500
    6000
    January 2012 July 2012 January 2013 July 2013 January 2014 July 2014 January 2015 July 2015 January 2016 July 2016 January 2017 July 2017
    Codehaus
    Bintray
    Maven Central
    End of Pivotal Support
    Gradle Kotlin Announcement

    View Slide

  79. @codeJENNerator
    Groovy Downloads in Thousands
    0
    1500
    3000
    4500
    6000
    January 2012 July 2012 January 2013 July 2013 January 2014 July 2014 January 2015 July 2015 January 2016 July 2016 January 2017 July 2017
    Codehaus
    Bintray
    Maven Central
    End of Pivotal Support
    Gradle Kotlin Announcement
    ???

    View Slide

  80. source: bintray

    View Slide

  81. source: bintray

    View Slide

  82. @codeJENNerator
    • Groovy downloads are up and higher than any
    time under Pivotal
    • In the last few years under Apache, Groovy has
    added many new contributors from various
    companies and individuals all over the world.
    • Although there is no single company is sponsoring
    the language, companies like OCI sponsor
    developers at least part-time.

    View Slide

  83. @codeJENNerator
    • Groovy releases are more frequent than in a long
    time.
    • Improvements coming in 2.5 including macros and
    2.6/3.0 with the parrot parser will majorly change
    Groovy for the better. Most of the work on the parrot
    parser comes from a new committer, Daniel Sun!
    • OCI’s support of the Grails framework means
    several people are dedicated to it and releases are
    frankly coming out faster than I can keep up.

    View Slide

  84. @codeJENNerator
    use code ctwgr8eu18

    View Slide

  85. @codeJENNerator

    View Slide

  86. @codeJENNerator
    Adding Groovy to your
    organization

    View Slide

  87. @codeJENNerator
    See if you are already using Groovy
    • Jenkins (Pipeline, Jobs Plugin, and many more!)
    • Spring Boot (optional Groovy support)
    • Apache Spark
    • SoapUI
    • JMeter
    • Tinkerpop (Gremlin)
    • Oracle NoSQL Database
    • Elasticsearch (deprecated)

    View Slide

  88. @codeJENNerator
    Spock
    • Groovy can be used in tests, but not in the end product if
    you don’t need it.
    • Once you start using Spock, you can add other awesome
    tools like Get and Test Containers

    View Slide

  89. @codeJENNerator
    Try a small POC
    • Frameworks like Grails are great for trying
    something out. If the team gets used to using
    Groovy for small projects, it might be easier to use it
    in more places later.

    View Slide

  90. @codeJENNerator
    Get Connected
    • Subscribe to the groovy users mailing list
    • Join the Groovy Community on Slack
    groovycommunity.com or sign-in again at groovy-
    community.slack.com
    • Contribute by writing documentation or fixing bugs.
    • Attend conferences like GR8Conf EU 2018.
    • Join Zenjob!

    View Slide

  91. @codeJENNerator
    Conclusion

    View Slide

  92. @codeJENNerator

    View Slide

  93. @codeJENNerator
    • Groovy is a fun language with a great community!

    View Slide

  94. @codeJENNerator
    • Groovy is a fun language with a great community!
    • You can use Groovy in many different ways!

    View Slide

  95. @codeJENNerator
    • Groovy is a fun language with a great community!
    • You can use Groovy in many different ways!
    • It isn’t an all-or-nothing solution. You can start small.

    View Slide

  96. @codeJENNerator
    • Groovy is a fun language with a great community!
    • You can use Groovy in many different ways!
    • It isn’t an all-or-nothing solution. You can start small.
    • Start talking about Groovy with your boss and
    coworkers and make sure they don’t keep spreading
    the Groovy myths. Keep them on the Groovy truth.

    View Slide

  97. @codeJENNerator
    • Groovy is a fun language with a great community!
    • You can use Groovy in many different ways!
    • It isn’t an all-or-nothing solution. You can start small.
    • Start talking about Groovy with your boss and
    coworkers and make sure they don’t keep spreading
    the Groovy myths. Keep them on the Groovy truth.

    • Rather than talking bad about problems with Apache
    Groovy, contribute! Anyone can shape the future.

    View Slide

  98. @codeJENNerator
    Feedback
    • Rate this talk: https://gr8conf.eu/talks
    • Send me new Groovy Truth of Myths

    View Slide

  99. @codeJENNerator
    Questions?
    https://flic.kr/p/5DeuzB

    View Slide