Your SlideShare is downloading. ×
10 Years of Groovy
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

10 Years of Groovy

924
views

Published on

10 Year retrospective of Groovy: the language and the ecosystem

10 Year retrospective of Groovy: the language and the ecosystem

Published in: Technology, Education

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
924
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1.
      A Very Groovy Birthday
    • Hamlet D'Arcy
    • 2. Canoo Engineering AG
    • 3. @HamletDRC
  • 4. A Very Groovy Birthday
    • Geneva JUG – 2 Years
    • 5. Hamlet D'Arcy
    • 6. Canoo Engineering AG
    • 7. @HamletDRC
  • 8. A Very Groovy Birthday
    • Geneva JUG – 2 Years Groovy – 10 th Year
    • 9. Hamlet D'Arcy
    • 10. Canoo Engineering AG
    • 11. @HamletDRC
  • 12. 2003
    • 13. 2003
      • 14. 2003 Closure
        • 15. “Refactored CompositeString to be called ______ :)”
        • 16. 2003 Closure GString
          • 17. 2003 Range Closure GString
            • 18. 2003 Range MarkupBuilder Closure GString
              • 19. new groovy.xml.MarkupBuilder().root() { ( 1 .. 3 ).each { child(id: "child $it " ) } }
              • 20. new groovy.xml.MarkupBuilder().root() { ( 1 .. 3 ).each { child(id: &quot;child $it &quot; ) } } <root> <child id='child1' /> <child id='child2' /> <child id='child3' /> </root>
              • 21. 2004 2003 Range MarkupBuilder Closure GString
                • 22. 2004 2003 JSR-241 Range MarkupBuilder Closure GString
                  • 23. 2004 2003 JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                    • 24. def text = '''Dear $person, So nice to meet you in <% print city %>. Sincerely, $signed''' def vars = [person: 'JUG' , city: 'Geneva' , signed: 'Hamlet' ] def engine = new groovy.text.SimpleTemplateEngine() engine.createTemplate(text).make(vars)
                    • 25. def text = '''Dear $person, So nice to meet you in <% print city %>. Sincerely, $signed''' def vars = [person: 'JUG' , city: 'Geneva' , signed: 'Hamlet' ] def engine = new groovy.text.SimpleTemplateEngine() engine.createTemplate(text).make(vars) Dear JUG, So nice to meet you in Geneva. Sincerely, Hamlet
                    • 26. 2005 2004 2003 JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                      • 27. 2005 2004 2003 XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                        • 28. 2005 2004 2003 XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                          • 29. 2005 2004 2003 XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                            • 30. 2006 2005 2004 2003 XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                              • 31. 2006 2005 2004 2003 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                  0.1-0.3
                                • 32. 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                    0.1-0.3
                                  • 33. 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                      0.1-0.3
                                    • 34. 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                        1.0, 1.5 0.1-0.3
                                      • 35. String. class .metaClass.default = { self -> self ?: '<unknown>' } '' .default()
                                      • 36. 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                          1.0, 1.5 0.4-0.7 0.1-0.3
                                        • 37. 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                            1.0, 1.5 0.4-0.7 0.1-0.3
                                          • 38. 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                              1.0, 1.5 0.4-0.7 0.1-0.3
                                            • 39. 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                1.0, 1.5 0.4-0.7 0.1-0.3
                                              • 40. 2008 2007 2006 2005 2004 2003 Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                  1.0, 1.5 0.4-0.7 0.1-0.3
                                                • 41. 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                    1.0, 1.5 0.4-0.7 0.1-0.3
                                                  • 42. @Grab( group= 'org.ccil.cowan.tagsoup' , module= 'tagsoup' , version= '1.2' ) import org.ccil.cowan.tagsoup.Parser def parser = new XmlParser(new Parser()) def url = 'http://twitter.com/hamletdrc' def html = parser.parse(url)
                                                  • 43. 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                      1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                    • 44. 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                        1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                      • 45. 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                          1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                        • 46. 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                            1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                          • 47. 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                              1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                            • 48. 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                              • 49. 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                  1.6, 1.7 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                • 50. def (x, y) = [ 1 , 2 ] @Singleton, @Lazy, @Immutable, @Delegate, ... and more
                                                                • 51. def (x, y) = [ 1 , 2 ] assert x == 1 assert y == 2
                                                                • 52. 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                    1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                  • 53. 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                      1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                    • 54. 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                        1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                      • 55. 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                          1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                        • 56. 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                            1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                          • 57. 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                              1.3 0.9 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                            • 58. 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                              • 59. 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                  1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                • 60. 2011 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                    1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                  • 61. 2011 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                      1.8 2.0 1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                    • 62. Command Chains stand 7.minutes at busstop ride 10.stops on bus towards Basel
                                                                                    • 63. JSON Builder import groovy.json.* def json = new JsonBuilder() json.person { name 'William Tell' status 'mythological' }
                                                                                    • 64. AST Transformations @ToString, @EqualsAndHashCode @TupleConstructor, @Canonical @Log, @Field, @Package, ... and many more
                                                                                    • 65. 2011 2010 2009 2008 2007 2006 2005 2004 2003 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                        1.0 1.8 2.0 1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                      • 66. 2011 2010 2009 2008 2007 2006 2005 2004 2003 2012 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                          1.0 1.8 2.0 1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                        • 67. 2011 2010 2009 2008 2007 2006 2005 2004 2003 2012 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                            1.0 1.0 0.17 1.0 1.8 2.0 1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                          • 68. 2011 2010 2009 2008 2007 2006 2005 2004 2003 2012 2.0 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                              1.0 1.0 0.17 1.0 1.8 2.0 1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3
                                                                                            • 69. void method(String message) { if (message != null ) { log.info( &quot;Received input: ${ message.toUppercase() }&quot; ) } }
                                                                                            • 70. @groovy.transform.TypeChecked void method(String message) { if (message != null ) { log.info( &quot;Received input: ${ message.toUppercase() }&quot; ) } }
                                                                                            • 71. @groovy.transform.TypeChecked void method(String message) { if (message != null ) { log.info( &quot;Received input: ${ message.toUppercase() }&quot; ) } } 1 compilation error: [Static type checking] - Cannot find matching method java.lang.String#toUppercase() at line: 4, column: 43
                                                                                            • 72. void method(Object message) { if (message instanceof String) { log.info( &quot;Received input: &quot; + message.toUpperCase() ); } }
                                                                                            • 73. @groovy.transform.TypeChecked void method(Object message) { if (message instanceof String) { log.info( &quot;Received input: ${ message.toUpperCase() }&quot; ) } }
                                                                                            • 74. def keys = [x: 1 ,y: 2 ,z: 3 ] *.key def values = [x: '1' ,y: '2' ,z: '3' ] *.value keys*.toUpperCase() values*.toUpperCase()
                                                                                            • 75. Dimension d1 = [ 100 ] Dimension d2 = [ '100' , '200' ] Dimension d3 = new Dimension( width: 100 , height: 100 , depth: 100 )
                                                                                            • 76. @groovy.transform.TypeChecked – Not a static compiler – No new syntax – No new semantics – Bytecode not changed – Targeted at Java developers
                                                                                            • 77. def v = 1 v = v.toString() println v.toUpperCase()
                                                                                            • 78. Flow Sensitive Typing def v = 1 v = v.toString() println v.toUpperCase()
                                                                                            • 79. Flow Sensitive Typing def v = 1 v = v.toString() println v.toUpperCase() – Under discussion
                                                                                            • 80. int fib(int i) { i < 2 ? 1 : fib(i - 2 ) + fib(i - 1 ) }
                                                                                            • 81. @groovy.transform.CompileStatic int fib(int i) { i < 2 ? 1 : fib(i - 2 ) + fib(i - 1 ) }
                                                                                            • 82. @groovy.transform.CompileStatic – Is a static compiler – No new syntax – Requires new semantics – Bytecode is changed
                                                                                            • 83. @groovy.transform.CompileStatic – Is a static compiler – No new syntax – Requires new semantics – Bytecode is changed – InvokeDynamic?
                                                                                            • 84. 2011 2010 2009 2008 2007 2006 2005 2004 2003 2012 2.0 @Grab Gant 0.3 Duration MockFor XmlSlurper JSR-241 SimpleTemplateEngine Range MarkupBuilder Closure GString
                                                                                                1.0 1.0 0.17 1.0 1.8 2.0 1.3 0.9 0.4, 0.5 1.6, 1.7 1.1, 1.2 1.0 1.0, 1.5 0.4-0.7 0.1-0.3