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.

1f28a0c1988421be3268026bd6bb6f49?s=128

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
  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.
  3. @codeJENNerator Follow Along https://speakerdeck.com/jlstrater/why-groovy-gr8conf-2018

  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

  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

  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.
  7. @codeJENNerator Audience Background

  8. @codeJENNerator Audience Background • Groovy • Everyday user • Side

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

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

    project user • New to Groovy • Frameworks / Tools • Grails • Spock • Gradle • Griffon • Jenkins
  11. @codeJENNerator –Andres Almiray @aalmiary “Groovy developers don’t seem to care

    about hype, they simply get the job done.”
  12. @codeJENNerator Outline • Why use Groovy? • Truth or Myth?

    • Ways to Start Using Groovy Today!
  13. None
  14. None
  15. @codeJENNerator Features

  16. None
  17. None
  18. None
  19. None
  20. None
  21. None
  22. None
  23. @codeJENNerator Ecosystem

  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. @codeJENNerator Community

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

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

    ecosystem • Friendly community
  35. @codeJENNerator

  36. @codeJENNerator Truth or Myth?

  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.
  38. @codeJENNerator Groovy is the same thing as Grails

  39. None
  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!
  41. @codeJENNerator Groovy is just a scripting language

  42. @codeJENNerator Yes and No

  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.
  44. @codeJENNerator James Strachan, the creator of Groovy, has left the

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

    community
  46. None
  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

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

  49. @codeJENNerator

  50. @codeJENNerator But…

  51. @codeJENNerator

  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.
  53. From Iván Lopez’s “ I've seen Grails code you wouldn't

    believe…” at Greach 2018 Slides
  54. @codeJENNerator Groovy is a dynamically typed language

  55. @codeJENNerator Not really

  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!
  57. @codeJENNerator Groovy is not suitable for production apps

  58. @codeJENNerator Not really

  59. @codeJENNerator

  60. @codeJENNerator Groovy is slow

  61. @codeJENNerator

  62. @codeJENNerator It depends!

  63. @codeJENNerator • It’s true that Groovy is slower than optimal

    Java, but not by as much as most people think.
  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.
  65. @codeJENNerator 8. Gradle is switching to Kotlin because Groovy sucks.

  66. None
  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
  68. @codeJENNerator You can write a project entirely in statically compiled

    Groovy
  69. None
  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
  71. @codeJENNerator Grails is Rails for the JVM

  72. None
  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.
  74. @codeJENNerator Groovy is dead

  75. @codeJENNerator

  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
  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
  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
  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 ???
  80. source: bintray

  81. source: bintray

  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.
  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.
  84. @codeJENNerator use code ctwgr8eu18

  85. @codeJENNerator

  86. @codeJENNerator Adding Groovy to your organization

  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)
  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
  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.
  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!
  91. @codeJENNerator Conclusion

  92. @codeJENNerator

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

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

    community! • You can use Groovy in many different ways!
  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.
  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.
  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.
  98. @codeJENNerator Feedback • Rate this talk: https://gr8conf.eu/talks • Send me

    new Groovy Truth of Myths
  99. @codeJENNerator Questions? https://flic.kr/p/5DeuzB