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

A Groovy journey in Open Source land

A Groovy journey in Open Source land

In dog years... err... Open Source years, the Groovy programming language project is a very mature and successful one, as its 12+ million downloads a year can attest. The Groovy language is certainly the most widely deployed alternative language of the JVM today. But how do we go from a hobby night & week-end project to professionally company sponsored? And back again to hobby mode but joining the wider Apache Software Foundation community?

Guillaume will guide you through the history of the project, its latest developments, and its recent news, outlining the importance of a community around an Open Source project.

Also, we'll discuss what it means to contribute, when it's your hobby or as a paid committer -- what does it change? What it means to join the Apache community, what the impact of professional Open Source is, and more.

Guillaume Laforge

June 02, 2016
Tweet

More Decks by Guillaume Laforge

Other Decks in Technology

Transcript

  1. A Groovy Journey in
    Open Source Land
    Guillaume Laforge / @glaforge
    Chair of the Apache Groovy PMC

    View Slide

  2. A Groovy Journey in
    Open Source Land
    Guillaume Laforge / @glaforge
    Chair of the Apache Groovy PMC

    View Slide

  3. View Slide

  4. GR8Conf Promo Code: ctwgr8conftw
    http://www.manning.com/koenig2/
    GROOVY
    IN ACTION
    2ND EDITION

    View Slide

  5. From 2003 onward…

    View Slide

  6. 2003

    View Slide

  7. Bob McWhirter
    James Strachan

    View Slide

  8. Bob McWhirter
    James Strachan
    James Strachan and Bob McWhirter
    gave birth to Groovy: a dynamic and
    agile scripting language for the JVM.
    […] James always used to say that
    it was all Bob's fault, but indeed,
    James had so many groovy ideas that
    it's hard to believe it's not his own
    fault. He kept saying: "Wouldn't it
    be groovy if we could do this and
    that...". Hence the name "Groovy".
    That's roughly how it all started.

    View Slide

  9. View Slide

  10. 7
    Groovy pre-1.0
    • Closures available since 2003 on Java 1.4+
    • All the nice shortcuts already, inspired by Python & Ruby
    • native syntax for lists, maps, etc…
    • Tons of useful methods to simplify 

    common Java boiler-plate code
    • Initially dynamically-typed only

    View Slide

  11. View Slide

  12. I join the project in
    2003, patches after
    patches, become
    committer, then lead
    when founders left

    View Slide

  13. 2004

    View Slide

  14. 5

    View Slide

  15. 11
    Groovy in 2004
    • A brand new parser based on Antlr
    • after two hand-rolled versions
    • by John Rose and Jeremy Rainer
    • Jochen « blackdrag » Theodorou joins the project

    View Slide

  16. View Slide

  17. View Slide

  18. 2005

    View Slide

  19. View Slide

  20. 2006

    View Slide

  21. 6

    View Slide

  22. 17
    First paid committer
    • Jochen becomes the first full-time paid committer
    • sponsored by BigSky Technologies / No Fluff Just Stuff

    View Slide

  23. 2007

    View Slide

  24. View Slide

  25. 1.0

    View Slide

  26. View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. View Slide

  31. Spock
    the Enterprise
    testing framework

    View Slide

  32. 24
    Groovy in 2007 — Groovy 1.5
    • The long awaited Java 5 update
    • annotations, enums, generics…
    • Joint compiler!
    • Varargs support
    • Static imports (including import aliasing)
    • Named parameters without parentheses

    View Slide

  33. View Slide

  34. Paul King, #1 committer
    from 2007 to 2010, and
    overall #1 committer too!

    View Slide

  35. 2008

    View Slide

  36. View Slide

  37. View Slide

  38. 29
    Griffon and Easyb

    View Slide

  39. 30
    Groovy++ fork!
    • Not the first fork, but 3rd
    • by Alex Tkachman (former G2One co-founder)
    • Big focus on static compilation
    • interesting playground for our forthcoming static type
    checking and static compilation support

    View Slide

  40. 2009

    View Slide

  41. I can honestly say if
    someone had shown
    me the Programming
    Scala book back in
    2003, I’d probably
    have never created
    Groovy

    View Slide

  42. Have I had JPA
    back then,
    I would
    certainly not
    have created
    Hibernate!

    View Slide

  43. View Slide

  44. View Slide

  45. View Slide

  46. View Slide

  47. View Slide

  48. View Slide

  49. View Slide

  50. View Slide

  51. View Slide

  52. View Slide

  53. View Slide

  54. 39
    The Groovy Ecosystem grows…

    View Slide

  55. 40
    Groovy 1.6
    • Performance improvements with call-site caching
    • Multiple assignments
    • Optional return in if/else, try/catch, switch/case
    • More AST transformations
    • @Singleton, @Lazy, @Immutable, @Delegate
    • The Grape module system with @Grab
    • OSGi support

    View Slide

  56. 41
    Groovy 1.7
    • Nested and inner classes, and nested static classes
    • Missing annotation definition support
    • Power Asserts from Spock
    • Customize the Groovy Truth!
    • AST viewer and AST builder
    • SQL support improvements

    View Slide

  57. 2010

    View Slide

  58. 43
    Groovy ecosystem marching on…
    GContracts

    View Slide

  59. 2011

    View Slide

  60. View Slide

  61. 7

    View Slide

  62. 47
    More Groovy ecosystem…

    View Slide

  63. 48
    Groovy 1.8
    • Command chain expressions
    • GPars bundled with the Groovy distribution
    • Primitive calculation optimizations
    • Closures
    • as annotation parameters
    • currying, memoization and tail recursion
    • Built-in JSON support

    View Slide

  64. I’m joining the
    Groovy team!

    View Slide

  65. View Slide

  66. 2012

    View Slide

  67. 52
    Groovy ecosystem continued…
    • Netflix
    • Asgard,
    • Zuul
    • LinkedIn Glu
    • GroovyStream

    View Slide

  68. 53
    Groovy 2.0
    • Static type checking and static compilation
    • type inference, flow typing…
    • « Project Coin » enhancements
    • binary literals, underscore in numbers, multicatch block
    • Initial « invoke dynamic » support
    • Modularity of the Groovy code base with modules

    View Slide

  69. 2013

    View Slide

  70. View Slide

  71. 56
    Richer Groovy ecosystem…

    View Slide

  72. 57
    Groovy 2.1
    • Full « invoke dynamic » support
    • Type-checking extensions
    • Meta-annotations
    • @DelegatesTo annotation
    • Compiler customization scripts
    • Distribution bundling GPars 1.0

    View Slide

  73. 58
    Groovy 2.2
    • Implicit closure coercion to SAM types
    • Java lambda friendly!
    • Pre-compiled type checking extensions
    • @Memoized transformations for methods

    View Slide

  74. 2014

    View Slide

  75. 8

    View Slide

  76. 61
    Groovy ecosystem

    View Slide

  77. 62
    Groovy 2.3
    • Traits!
    • Improved JDK 8 support
    • Drastic performance improvement for JSON
    • New AST transformations & improvements
    • @Builder,@Sortable,@SourceURI, @BaseScript
    • New markup template engine
    • More NIO support

    View Slide

  78. 2015

    View Slide

  79. You’re
    fired!
    2015

    View Slide

  80. View Slide

  81. Oh by the
    way,
    Codehaus
    closes!

    View Slide

  82. ANY
    IMPACT?

    View Slide

  83. 2012 2013 2014 2015
    Downloads

    View Slide

  84. 2012 2013 2014 2015
    1.7M
    3M
    4.5M
    Downloads 12.7M

    View Slide

  85. 3.4 MILLIONS
    FROM MAVEN CENTRAL
    IN 4 MONTHS

    View Slide

  86. MAVEN
    CENTRAL
    ONLY

    View Slide

  87. MAVEN
    CENTRAL
    ONLY
    +BINTRAY

    View Slide

  88. 3 MILLIONS
    FROM BINTRAY

    View Slide

  89. 6.4 MILLIONS
    ALREADY IN
    2016 SO FAR

    View Slide

  90. GROOVY
    2.4

    View Slide

  91. 72
    Groovy 2.4 — Android support
    • Write your Android applications
    fully in Groovy!
    • Dedicated Gradle plugin

    View Slide

  92. 73
    Groovy 2.4 — Android support
    SwissKnife

    a dedicated 

    Groovy / Android 

    library

    View Slide

  93. 74
    Groovy 2.4 — Performance & bytecode
    • Improved bytecode
    • cheaper comparison operations
    • optimization of primitive type coercions with ‘as’
    • Reduced bytecode size
    • no MOP generated methods in static context
    • uneeded inner class distributor methods when no inner
    • timestamp removal
    • Reduced memory consumption

    View Slide

  94. 75
    Groovy 2.4 — Traits @SelfType
    class Component {

    void doSomething() {

    println "Done!"

    }

    }

    View Slide

  95. 75
    Groovy 2.4 — Traits @SelfType
    class Component {

    void doSomething() {

    println "Done!"

    }

    }
    import groovy.transform.*

    @SelfType(Component)

    @TypeChecked

    trait ComponentDecorator {

    void logAndDoSomething() {

    println "Going to do something"

    doSomething()

    }

    }

    View Slide

  96. 75
    Groovy 2.4 — Traits @SelfType
    class Component {

    void doSomething() {

    println "Done!"

    }

    }
    import groovy.transform.*

    @SelfType(Component)

    @TypeChecked

    trait ComponentDecorator {

    void logAndDoSomething() {

    println "Going to do something"

    doSomething()

    }

    }
    class ConcreteComponent

    extends Component

    implements ComponentDecorator {}


    def c = new ConcreteComponent()

    c.logAndDoSomething()

    View Slide

  97. 76
    Groovy 2.4 — GDK improvements
    • New methods
    • System.currentTimeSeconds()
    • List: removeAt(index), getIndices()
    • Collection: removeElement(Object)
    • Iterable: disjoin(), size(), dropRight(),
    takeRight()
    • More collection methods moved to iterator-based
    • Favor stream-like traversal methods leveraging iterables
    • Consistency for mutation in place vs new collection creation

    View Slide

  98. 77
    Groovy 2.4 — AST transformations
    • @ToString added includeSuperProperties parameter
    • Can define compilation phase for @ASTTest
    • @Synchronized supports explicit static locks used by
    instance methods if needed
    • Cleaned-up code for @AutoExternalizable and
    @EqualsAndHashCode when used with @CompileStatic
    • Improved Java integration for @Builder
    • @PackageScope allowed on constructors

    View Slide

  99. 78
    Groovy 2.4 — Groovysh improvements
    • Custom .rc and .profile scripts
    • instanceof completion
    • Static members completion only in a static context
    • Completion candidates in color
    • :set interpreterMode to remember locally-defined variables
    • :load command supports file names with spaces
    • Align arguments & flags with the groovy command
    • Script launch on startup & continue execution of Groovysh
    • Easier to subclass Groovysh for embedded reuse

    View Slide

  100. Here come the Indians!

    View Slide

  101. View Slide

  102. MESSAGE TO THE
    COMMUNITY

    View Slide

  103. HERE TO
    STAY

    View Slide

  104. HERE TO
    STAY
    INDEPENDENCE

    View Slide

  105. HERE TO
    STAY
    COMMUNITY
    ABOVE ALL
    INDEPENDENCE

    View Slide

  106. 83
    Top Level Project at Apache!
    • PMC & Incubator PMC voted for graduation
    • Apache Board agreed to the graduation!
    • (last November)
    • Call us Apache Groovy :-)
    • 2.4.6 was released on February 2016

    View Slide

  107. 84
    Entering the TIOBE index
    • 3 months in a row in the top-20 TIOBE index
    • 17th for January
    • 20th for February
    • 17th for March
    • 17th for April
    • 17th for May

    View Slide

  108. View Slide

  109. Little nuggets…

    View Slide

  110. 87
    Groovy 2.4.4/5/6 / 2.5
    • Improved compiler performance
    • with an ASM class reader
    • @Canonical becomes a meta-annotation
    • More control on the meta-annotation collector
    • New @MapConstructor transformation
    • Pre/post conditions for @TupleConstructor
    • Property validation in transformation parameters
    • @Delegate on getters
    • Further AST transformation improvements
    • JAXB marshal/unmarshal shortcuts

    View Slide

  111. 88
    @Canonical becomes a meta-annotation
    import groovy.transform.*


    @Canonical(includeNames = true)

    class Person {

    String name

    int age

    }


    assert new Person('Guillaume', 38).toString() ==

    'Person(name:Guillaume, age:38)'

    View Slide

  112. 88
    @Canonical becomes a meta-annotation
    import groovy.transform.*


    @Canonical(includeNames = true)

    class Person {

    String name

    int age

    }


    assert new Person('Guillaume', 38).toString() ==

    'Person(name:Guillaume, age:38)'
    includeNames
    from @ToString

    View Slide

  113. 89
    More control on annotation collector
    DUPLICATE
    Annotations from the annotation
    collection will always be inserted.
    PREFER_COLLECTOR
    Annotations from the collector will be
    added and any existing annotations with
    the same name will be removed.
    PREFER_EXPLICIT
    Annotations from the collector will be
    ignored if any existing annotations with
    the same name are found.
    PREFER_EXPLICIT_MERGED
    Annotations from the collector will be
    ignored if any existing annotations with
    the same name are found but any new
    parameters on the collector annotation
    will be added to existing annotations.
    PREFER_COLLECTOR_MERGED
    Annotations from the collector will be
    added and any existing annotations with
    the same name will be removed but any
    new parameters found within existing
    annotations will be merged into the
    added annotation.

    View Slide

  114. 90
    New @MapConstructor transformation
    import groovy.transform.*


    @TupleConstructor

    class Person {

    String first, last

    }


    @CompileStatic // optional

    @ToString(includeSuperProperties = true)

    @MapConstructor(pre = { super(args?.first, args?.last);

    args = args ?: [:] },

    post = { first = first?.toUpperCase() })

    class Author extends Person {

    String bookName

    }
    assert new Author(first: 'Dierk',
    last: 'Koenig',
    bookName: 'ReGinA').toString() ==
    'Author(ReGinA, DIERK, Koenig)'


    assert new Author().toString() ==
    'Author(null, null, null)'

    View Slide

  115. 90
    New @MapConstructor transformation
    import groovy.transform.*


    @TupleConstructor

    class Person {

    String first, last

    }


    @CompileStatic // optional

    @ToString(includeSuperProperties = true)

    @MapConstructor(pre = { super(args?.first, args?.last);

    args = args ?: [:] },

    post = { first = first?.toUpperCase() })

    class Author extends Person {

    String bookName

    }
    assert new Author(first: 'Dierk',
    last: 'Koenig',
    bookName: 'ReGinA').toString() ==
    'Author(ReGinA, DIERK, Koenig)'


    assert new Author().toString() ==
    'Author(null, null, null)'
    Can decorate map
    ctor with pre / post-
    instructions

    View Slide

  116. 91
    Pre/post events for @TupleConstructor
    import groovy.transform.TupleConstructor
    @TupleConstructor(pre = { first = first?.toLowerCase() })
    class Person {
    String first
    }
    def p = new Person('Jack')
    assert p.first == 'jack'

    View Slide

  117. 91
    Pre/post events for @TupleConstructor
    import groovy.transform.TupleConstructor
    @TupleConstructor(pre = { first = first?.toLowerCase() })
    class Person {
    String first
    }
    def p = new Person('Jack')
    assert p.first == 'jack'
    import groovy.transform.TupleConstructor
    import static groovy.test.GroovyAssert.shouldFail
    @TupleConstructor(pre = { assert first })
    class Person {
    String first
    }
    def p = new Person('Jack')
    shouldFail {
    def unknown = new Person()
    }

    View Slide

  118. 92
    Properties validated in AST xforms
    import groovy.transform.AutoClone


    @AutoClone(excludes = 'sirName')

    class Person {

    String firstName

    String surName

    }


    new Person(firstName: "John",
    surName: "Doe").clone()

    View Slide

  119. 92
    Properties validated in AST xforms
    import groovy.transform.AutoClone


    @AutoClone(excludes = 'sirName')

    class Person {

    String firstName

    String surName

    }


    new Person(firstName: "John",
    surName: "Doe").clone()
    Error during @AutoClone
    processing: 'excludes'
    property 'sirName'
    does not exist.

    View Slide

  120. 93
    Prevent @TupleConstructor default ctors
    @TupleConstructor

    class Person {

    String first, last

    int age

    }

    View Slide

  121. 93
    Prevent @TupleConstructor default ctors
    @TupleConstructor

    class Person {

    String first, last

    int age

    }
    Generates:
    Person(String first, String last, int age) { /*...*/ }
    Person(String first, String last) { this(first, last, 0) }
    Person(String first) { this(first, null) }
    Person() { this(null) }

    View Slide

  122. 94
    Prevent @TupleConstructor default ctors
    @TupleConstructor(defaults = true)

    class Person {
    String first, last

    int age

    }

    View Slide

  123. 94
    Prevent @TupleConstructor default ctors
    @TupleConstructor(defaults = true)

    class Person {
    String first, last

    int age

    }
    Generates only:
    Person(String first, String last, int age) { /*...*/ }

    View Slide

  124. 95
    @Immutable support in class hierarchy
    import groovy.transform.*


    @EqualsAndHashCode

    class Person {

    String name

    }

    View Slide

  125. 95
    @Immutable support in class hierarchy
    import groovy.transform.*


    @EqualsAndHashCode

    class Person {

    String name

    }
    @Immutable

    @TupleConstructor(includeSuperProperties = true)

    @EqualsAndHashCode(callSuper = true)

    @ToString(includeNames = true, includeSuperProperties = true)

    class Athlete extends Person {

    String sport

    }

    View Slide

  126. 95
    @Immutable support in class hierarchy
    import groovy.transform.*


    @EqualsAndHashCode

    class Person {

    String name

    }
    @Immutable

    @TupleConstructor(includeSuperProperties = true)

    @EqualsAndHashCode(callSuper = true)

    @ToString(includeNames = true, includeSuperProperties = true)

    class Athlete extends Person {

    String sport

    }
    def d1 = new Athlete('Michael Jordan', 'BasketBall')

    def d2 = new Athlete(name: 'Roger Federer', sport: ‘Tennis')
    assert d1 != d2

    assert d1.toString() == 

    'Athlete(sport:BasketBall, name:Michael Jordan)'

    assert d2.toString() == 

    'Athlete(sport:Tennis, name:Roger Federer)'

    View Slide

  127. 96
    :grab command in groovysh
    groovy:000> :grab 'com.google.guava:guava:19.0'
    groovy:000> import com.google.common.collect.BiMap
    ===> com.google.common.collect.BiMap

    View Slide

  128. 97
    @Delegate on getters too
    class Person {

    String name
    @Delegate

    String getName() {
    name.toUpperCase()
    }
    }
    def p = new Person('Bill')
    assert p.toUpperCase() == 'BILL'

    View Slide

  129. 98
    JAXB marshalling shortcuts
    import groovy.transform.EqualsAndHashCode
    import javax.xml.bind.JAXBContext
    import javax.xml.bind.annotation.*
    @EqualsAndHashCode
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlRootElement
    class Person {
    String name
    int age
    }

    View Slide

  130. 98
    JAXB marshalling shortcuts
    import groovy.transform.EqualsAndHashCode
    import javax.xml.bind.JAXBContext
    import javax.xml.bind.annotation.*
    @EqualsAndHashCode
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlRootElement
    class Person {
    String name
    int age
    }
    def jaxbContext =
    JAXBContext.newInstance(Person)
    def p = new Person(name: 'Bill', age: 20)
    def xml = jaxbContext.marshal(p)
    assert jaxbContext.unmarshal(xml, Person) == p

    View Slide

  131. 99
    Miscellaneous
    • Map#retainAll {} and Map#removeAll {} methods
    • GDK’s createSimilarCollection() and
    createSimilarMap() methods support all the JDK’s
    collections and maps
    • New File#relativePath(file) method

    View Slide

  132. To conclude…

    View Slide

  133. View Slide

  134. It’s been a long road!
    And it’s not over yet!

    View Slide

  135. View Slide

  136. Thanks for your attention!

    View Slide

  137. Questions & Answers

    View Slide