Save 37% off PRO during our Black Friday Sale! »

Groovy State of the Union — GR8Conf Europe 2015

Groovy State of the Union — GR8Conf Europe 2015

137d3908243acfc30e126615d59d4e6d?s=128

Guillaume Laforge

June 03, 2015
Tweet

Transcript

  1. State of the Union Guillaume Laforge @glaforge Restlet — the

    Web API platform Groovy project team
  2. We know about APIs!

  3. STATE OF THE UNION

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

  6. A look back at the past 6 months

  7. FIRED!

  8. MARCH 31st

  9. MARCH 31st RELEASE GROOVY 2.4 GRAILS 3.0

  10. None
  11. What could possibly go wrong?

  12. None
  13. THE CODEHAUS DEMISE

  14. IMPACT?

  15. 2012 2013 2014 2015 Downloads

  16. 2012 2013 2014 2015 1.7M 3M 4.5M ? Downloads

  17. 2.1 MILLIONS FOR FIRST 4 MONTHS OF 2015

  18. MAVEN CENTRAL ONLY

  19. MAVEN CENTRAL ONLY +CODEHAUS LEGACY

  20. MAVEN CENTRAL ONLY +CODEHAUS LEGACY +BINTRAY

  21. GROOVY 2.4

  22. 15 Groovy 2.4 — Android support • Write your Android

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

    applications fully in Groovy! • Dedicated Gradle plugin
  24. 16 Groovy 2.4 — Android support SwissKnife
 a dedicated 


    Groovy / Android 
 library
  25. 17 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
  26. 18 Groovy 2.4 — Traits @SelfType class Component {
 void

    doSomething() {
 println "Done!"
 }
 }
  27. 18 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()
 }
 }
  28. 18 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()
  29. 19 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
  30. 20 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
  31. 21 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
  32. And now, what’s next?

  33. MUSICAL CHAIRS

  34. GRAILS GROOVY CEDRIC GUILLAUME JOCHEN LARI JEFF GRAEME ?

  35. GRAILS GROOVY CEDRIC GUILLAUME JOCHEN LARI JEFF GRAEME ?

  36. None
  37. MESSAGE TO THE COMMUNITY

  38. HERE TO STAY

  39. HERE TO STAY INDEPENDENCE

  40. HERE TO STAY COMMUNITY ABOVE ALL INDEPENDENCE

  41. APACHE INCUBATOR

  42. APACHE INCUBATOR MARCH 24TH

  43. 29 Incubation — mentors • Emmanuel Lécharny • Bertrand Delacrétaz

    • Roman Shaposhnik • Jim Jagielski • Andrew Bayer
  44. 30 Incubation — initial committers • Paul King • Cédric

    Champeau • Pascal Schumacher • Jochen Theodorou • Guillaume Laforge
  45. 31 Incubation — infrastructure • Mailing-lists created • please don’t

    use the old ones! • JIRA issues imported • Sources moved to Apache’s Git • with a mirror on Github Please Star it!
  46. 32 Incubation — new committers • Officially joined the project

    as committer • Andrés Almiray • To be announced soon too! • Dierk König • Russel Winder
  47. 33 Incubation — next steps • The next key step

    is make a first release! • following the Apache guidelines
  48. Little nuggets to come… For Groovy 2.4.4 and Groovy 2.5

  49. 35 @Canonical becomes a meta-annotation import groovy.transform.*
 
 @Canonical(includeNames =

    true)
 class Person {
 String name
 int age
 }
 
 assert new Person('Guillaume', 37).toString() ==
 'Person(name:Guillaume, age:37)'
  50. 35 @Canonical becomes a meta-annotation import groovy.transform.*
 
 @Canonical(includeNames =

    true)
 class Person {
 String name
 int age
 }
 
 assert new Person('Guillaume', 37).toString() ==
 'Person(name:Guillaume, age:37)' includeNames from @ToString
  51. 36 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.
  52. 37 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)'
  53. 37 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
  54. 38 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()
  55. 38 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.
  56. 39 Prevent @TupleConstructor default ctors @TupleConstructor
 class Person {
 String

    first, last
 int age
 }
  57. 39 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) }
  58. 40 Prevent @TupleConstructor default ctors @TupleConstructor(defaults = true)
 class Person

    { String first, last
 int age
 }
  59. 40 Prevent @TupleConstructor default ctors @TupleConstructor(defaults = true)
 class Person

    { String first, last
 int age
 } Generates only: Person(String first, String last, int age) { /*...*/ }
  60. 41 @Immutable support in class hierarchy import groovy.transform.*
 
 @EqualsAndHashCode


    class Person {
 String name
 }
  61. 41 @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
 }
  62. 41 @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 Rederer', sport: ‘Tennis') assert d1 != d2
 assert d1.toString() == 
 'Athlete(sport:BasketBall, name:Michael Jordan)'
 assert d2.toString() == 
 'Athlete(sport:Tennis, name:Roger Rederer)'
  63. 42 Miscellaneous • GDK’s createSimilarCollection() and createSimilarMap() methods support all

    the JDK’s collections and maps • Improve compiler performance with an ASM class reader instead of using a class loader • New File#relativePath(file) method
  64. Thanks for your attention!

  65. Questions & Answers