Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
ThoughtWorks




               comparing
          groovy & jruby *
* please check all knives, guns, pitchforks, and torc...
housekeeping
ask questions at the end
(insane amount of material!)


download slides from
nealford.com



download samples...
agenda:
syntax

closures

eigenclass approaches

meta-programming

framework approach
geek fu test:
Groovy dynamicizes   JRuby brings Ruby to
 the Java platform
       TM

                       the Java platform
         ...
differences & observations
syntax
sigils
this.name

   vs

 @name
auto-encapsulation?
Perl !!!!!!!!!
Ruby has some Perl-isms...

...with significant differences
closures
passing closures
auto-blocks
passing closures
everything except...
in Java™, everything is an object...

...except primitives and nulls

in Groovy, everything is an obj...
null is null


 ?. handles protected
      reference

person?.address?.street
nil is an instance of
   NilClass
switch/case statement
===   isCase()
“spread” operator
“elvis” operator
side effects of
encapsulating
    Java™
things added to Object
supporting collections
really? really!
JRuby additions
    JRuby adds artifacts to “Rubify” Java™




ArrayList


                                             Fi...
Groovy is (kind of)
optionally typed
search exists on Stack




but not on ArrayList
      or List!
interfaces & mixins
Groovy & interfaces

allows you to interact with Java™ interfaces


can wrap proxies around them if needed


“fake out” in...
be careful when implementing with a map:
NullPointerException if you forget a method
Ruby has no interfaces
mixin

first appeared in symbolic logic’s flavors system

named after ice cream mix-ins

not a form o...
comparisons
comparisons
comparisons
violating handshakes
mixins in Groovy,
interfaces in JRuby
interfaces in JRuby?
meta-programming
mostly parity (functionally)




very different implementations
executable declarations
much of Ruby’s infrastructure is meta-
programming

meta-programming methods:

   attr_reader, att...
AST transformations
implementation
optional inclusion
conditional method
attributes
hook methods
sticky attributes




private, protected, public
eigenclass
adding methods via
      proxies
Groovy’s eigenclass
framework
 approach
encapsulate
 & extend
Groovy & Grails
leverage the existing industrial strength Java™
stack

encapsulate best-of-breed frameworks

use Groovy to...
abstraction
layers
via
meta || dsl
Ruby

tends to build things as abstraction layers atop
Ruby using meta-programming & dsl techniques

Ruby on Rails = softw...
case study: builders
GroovyObjectSupport




  BuilderSupport




   MarkupBuilder
builder
builder works via
method_missing

 but what about this?
the problem:

how do you inherit from object...

 ...with inheriting from object?
Jim Weirich’s
           1.8     BlankSlate

 Object           BasicObject
                  BlankSlate




Builder
Record...
different philosophies

Groovy encapsulates and builds up

Ruby either builds

   abstractions with dsl’s

   via meta-pro...
summary
the good
unparalleled Java™ integration

willing to evolve the language

the real JDK™ 2.0!

building up from best-of-breed
the bad
fast changing at the core

single runtime platform

never spread out of the Java™ community

framework approach?
def name

     public String getName()
public void setName(String name)
the good
well established (older than Java™)

virtually effortless meta-programming

futuristic framework approach

truly ...
the bad
some impedance mismatch with Java™ (smaller
all the time)

yet another language to learn

unfamiliar frameworks

y...
ThoughtWorks




                                ?’s
            please fill out the session evaluations
             sampl...
ThoughtWorks




                    resources
Cow in the Road photo by Sophia Huda, from
Flickr, under a Creative Commons...
ThoughtWorks




                     resources
jeff brown’s blog
http://javajeff.blogspot.com/

graeme rocher’s blog
http...
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Comparing groovy and_j_ruby(neal_ford)
Upcoming SlideShare
Loading in …5
×

of

Comparing groovy and_j_ruby(neal_ford) Slide 1 Comparing groovy and_j_ruby(neal_ford) Slide 2 Comparing groovy and_j_ruby(neal_ford) Slide 3 Comparing groovy and_j_ruby(neal_ford) Slide 4 Comparing groovy and_j_ruby(neal_ford) Slide 5 Comparing groovy and_j_ruby(neal_ford) Slide 6 Comparing groovy and_j_ruby(neal_ford) Slide 7 Comparing groovy and_j_ruby(neal_ford) Slide 8 Comparing groovy and_j_ruby(neal_ford) Slide 9 Comparing groovy and_j_ruby(neal_ford) Slide 10 Comparing groovy and_j_ruby(neal_ford) Slide 11 Comparing groovy and_j_ruby(neal_ford) Slide 12 Comparing groovy and_j_ruby(neal_ford) Slide 13 Comparing groovy and_j_ruby(neal_ford) Slide 14 Comparing groovy and_j_ruby(neal_ford) Slide 15 Comparing groovy and_j_ruby(neal_ford) Slide 16 Comparing groovy and_j_ruby(neal_ford) Slide 17 Comparing groovy and_j_ruby(neal_ford) Slide 18 Comparing groovy and_j_ruby(neal_ford) Slide 19 Comparing groovy and_j_ruby(neal_ford) Slide 20 Comparing groovy and_j_ruby(neal_ford) Slide 21 Comparing groovy and_j_ruby(neal_ford) Slide 22 Comparing groovy and_j_ruby(neal_ford) Slide 23 Comparing groovy and_j_ruby(neal_ford) Slide 24 Comparing groovy and_j_ruby(neal_ford) Slide 25 Comparing groovy and_j_ruby(neal_ford) Slide 26 Comparing groovy and_j_ruby(neal_ford) Slide 27 Comparing groovy and_j_ruby(neal_ford) Slide 28 Comparing groovy and_j_ruby(neal_ford) Slide 29 Comparing groovy and_j_ruby(neal_ford) Slide 30 Comparing groovy and_j_ruby(neal_ford) Slide 31 Comparing groovy and_j_ruby(neal_ford) Slide 32 Comparing groovy and_j_ruby(neal_ford) Slide 33 Comparing groovy and_j_ruby(neal_ford) Slide 34 Comparing groovy and_j_ruby(neal_ford) Slide 35 Comparing groovy and_j_ruby(neal_ford) Slide 36 Comparing groovy and_j_ruby(neal_ford) Slide 37 Comparing groovy and_j_ruby(neal_ford) Slide 38 Comparing groovy and_j_ruby(neal_ford) Slide 39 Comparing groovy and_j_ruby(neal_ford) Slide 40 Comparing groovy and_j_ruby(neal_ford) Slide 41 Comparing groovy and_j_ruby(neal_ford) Slide 42 Comparing groovy and_j_ruby(neal_ford) Slide 43 Comparing groovy and_j_ruby(neal_ford) Slide 44 Comparing groovy and_j_ruby(neal_ford) Slide 45 Comparing groovy and_j_ruby(neal_ford) Slide 46 Comparing groovy and_j_ruby(neal_ford) Slide 47 Comparing groovy and_j_ruby(neal_ford) Slide 48 Comparing groovy and_j_ruby(neal_ford) Slide 49 Comparing groovy and_j_ruby(neal_ford) Slide 50 Comparing groovy and_j_ruby(neal_ford) Slide 51 Comparing groovy and_j_ruby(neal_ford) Slide 52 Comparing groovy and_j_ruby(neal_ford) Slide 53 Comparing groovy and_j_ruby(neal_ford) Slide 54 Comparing groovy and_j_ruby(neal_ford) Slide 55 Comparing groovy and_j_ruby(neal_ford) Slide 56 Comparing groovy and_j_ruby(neal_ford) Slide 57 Comparing groovy and_j_ruby(neal_ford) Slide 58 Comparing groovy and_j_ruby(neal_ford) Slide 59 Comparing groovy and_j_ruby(neal_ford) Slide 60 Comparing groovy and_j_ruby(neal_ford) Slide 61 Comparing groovy and_j_ruby(neal_ford) Slide 62 Comparing groovy and_j_ruby(neal_ford) Slide 63 Comparing groovy and_j_ruby(neal_ford) Slide 64 Comparing groovy and_j_ruby(neal_ford) Slide 65 Comparing groovy and_j_ruby(neal_ford) Slide 66 Comparing groovy and_j_ruby(neal_ford) Slide 67 Comparing groovy and_j_ruby(neal_ford) Slide 68 Comparing groovy and_j_ruby(neal_ford) Slide 69 Comparing groovy and_j_ruby(neal_ford) Slide 70 Comparing groovy and_j_ruby(neal_ford) Slide 71 Comparing groovy and_j_ruby(neal_ford) Slide 72 Comparing groovy and_j_ruby(neal_ford) Slide 73 Comparing groovy and_j_ruby(neal_ford) Slide 74 Comparing groovy and_j_ruby(neal_ford) Slide 75 Comparing groovy and_j_ruby(neal_ford) Slide 76 Comparing groovy and_j_ruby(neal_ford) Slide 77 Comparing groovy and_j_ruby(neal_ford) Slide 78 Comparing groovy and_j_ruby(neal_ford) Slide 79 Comparing groovy and_j_ruby(neal_ford) Slide 80 Comparing groovy and_j_ruby(neal_ford) Slide 81 Comparing groovy and_j_ruby(neal_ford) Slide 82 Comparing groovy and_j_ruby(neal_ford) Slide 83 Comparing groovy and_j_ruby(neal_ford) Slide 84 Comparing groovy and_j_ruby(neal_ford) Slide 85 Comparing groovy and_j_ruby(neal_ford) Slide 86 Comparing groovy and_j_ruby(neal_ford) Slide 87 Comparing groovy and_j_ruby(neal_ford) Slide 88 Comparing groovy and_j_ruby(neal_ford) Slide 89 Comparing groovy and_j_ruby(neal_ford) Slide 90 Comparing groovy and_j_ruby(neal_ford) Slide 91 Comparing groovy and_j_ruby(neal_ford) Slide 92 Comparing groovy and_j_ruby(neal_ford) Slide 93 Comparing groovy and_j_ruby(neal_ford) Slide 94 Comparing groovy and_j_ruby(neal_ford) Slide 95 Comparing groovy and_j_ruby(neal_ford) Slide 96 Comparing groovy and_j_ruby(neal_ford) Slide 97 Comparing groovy and_j_ruby(neal_ford) Slide 98 Comparing groovy and_j_ruby(neal_ford) Slide 99 Comparing groovy and_j_ruby(neal_ford) Slide 100 Comparing groovy and_j_ruby(neal_ford) Slide 101 Comparing groovy and_j_ruby(neal_ford) Slide 102 Comparing groovy and_j_ruby(neal_ford) Slide 103
Upcoming SlideShare
Командообразование
Next
Download to read offline and view in fullscreen.

0 Likes

Share

Download to read offline

Comparing groovy and_j_ruby(neal_ford)

Download to read offline

Presentation of Neal Ford on JavaOne 2010

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Comparing groovy and_j_ruby(neal_ford)

  1. 1. ThoughtWorks comparing groovy & jruby * * please check all knives, guns, pitchforks, and torches at the door NEAL FORD software architect / meme wrangler ThoughtWorks nford@thoughtworks.com 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com blog: memeagora.blogspot.com twitter: neal4d
  2. 2. housekeeping ask questions at the end (insane amount of material!) download slides from nealford.com download samples from github.com/nealford
  3. 3. agenda: syntax closures eigenclass approaches meta-programming framework approach
  4. 4. geek fu test:
  5. 5. Groovy dynamicizes JRuby brings Ruby to the Java platform TM the Java platform TM
  6. 6. differences & observations
  7. 7. syntax
  8. 8. sigils
  9. 9. this.name vs @name
  10. 10. auto-encapsulation?
  11. 11. Perl !!!!!!!!!
  12. 12. Ruby has some Perl-isms... ...with significant differences
  13. 13. closures
  14. 14. passing closures
  15. 15. auto-blocks
  16. 16. passing closures
  17. 17. everything except... in Java™, everything is an object... ...except primitives and nulls in Groovy, everything is an object... except null in JRuby, everything is an object.
  18. 18. null is null ?. handles protected reference person?.address?.street
  19. 19. nil is an instance of NilClass
  20. 20. switch/case statement
  21. 21. === isCase()
  22. 22. “spread” operator
  23. 23. “elvis” operator
  24. 24. side effects of encapsulating Java™
  25. 25. things added to Object
  26. 26. supporting collections
  27. 27. really? really!
  28. 28. JRuby additions JRuby adds artifacts to “Rubify” Java™ ArrayList Fixnum ...but doesn’t add collection stuff to Object
  29. 29. Groovy is (kind of) optionally typed
  30. 30. search exists on Stack but not on ArrayList or List!
  31. 31. interfaces & mixins
  32. 32. Groovy & interfaces allows you to interact with Java™ interfaces can wrap proxies around them if needed “fake out” interfaces via closures using as
  33. 33. be careful when implementing with a map: NullPointerException if you forget a method
  34. 34. Ruby has no interfaces mixin first appeared in symbolic logic’s flavors system named after ice cream mix-ins not a form of specialization a way to collect functionality
  35. 35. comparisons
  36. 36. comparisons
  37. 37. comparisons
  38. 38. violating handshakes
  39. 39. mixins in Groovy, interfaces in JRuby
  40. 40. interfaces in JRuby?
  41. 41. meta-programming
  42. 42. mostly parity (functionally) very different implementations
  43. 43. executable declarations much of Ruby’s infrastructure is meta- programming meta-programming methods: attr_reader, attr_writer, attr_accessor include private, protected, public
  44. 44. AST transformations
  45. 45. implementation
  46. 46. optional inclusion
  47. 47. conditional method
  48. 48. attributes
  49. 49. hook methods
  50. 50. sticky attributes private, protected, public
  51. 51. eigenclass
  52. 52. adding methods via proxies
  53. 53. Groovy’s eigenclass
  54. 54. framework approach
  55. 55. encapsulate & extend
  56. 56. Groovy & Grails leverage the existing industrial strength Java™ stack encapsulate best-of-breed frameworks use Groovy to simplify and humanize them encapsulate, then build up
  57. 57. abstraction layers via meta || dsl
  58. 58. Ruby tends to build things as abstraction layers atop Ruby using meta-programming & dsl techniques Ruby on Rails = software factories + dsl’s Ruby language is always 1 abstraction layer down lightweight abstraction layers
  59. 59. case study: builders
  60. 60. GroovyObjectSupport BuilderSupport MarkupBuilder
  61. 61. builder
  62. 62. builder works via method_missing but what about this?
  63. 63. the problem: how do you inherit from object... ...with inheriting from object?
  64. 64. Jim Weirich’s 1.8 BlankSlate Object BasicObject BlankSlate Builder Recorder Builder Recorder Recorder 1.9 BasicObject
  65. 65. different philosophies Groovy encapsulates and builds up Ruby either builds abstractions with dsl’s via meta-programming
  66. 66. summary
  67. 67. the good unparalleled Java™ integration willing to evolve the language the real JDK™ 2.0! building up from best-of-breed
  68. 68. the bad fast changing at the core single runtime platform never spread out of the Java™ community framework approach?
  69. 69. def name public String getName() public void setName(String name)
  70. 70. the good well established (older than Java™) virtually effortless meta-programming futuristic framework approach truly cross platform, for the new definition of platform interpreted, then jit-ted
  71. 71. the bad some impedance mismatch with Java™ (smaller all the time) yet another language to learn unfamiliar frameworks you have to switch to a new community you have to learn to think like a Ruby-ist
  72. 72. ThoughtWorks ?’s please fill out the session evaluations samples at github.com/nealford NEAL FORD software architect / meme wrangler ThoughtWorks nford@thoughtworks.com This work is licensed under the Creative Commons 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com Attribution-Share Alike 3.0 License. www.thoughtworks.com blog: memeagora.blogspot.com http://creativecommons.org/licenses/by-sa/3.0/us/ twitter: neal4d
  73. 73. ThoughtWorks resources Cow in the Road photo by Sophia Huda, from Flickr, under a Creative Commons license groovy web site http://groovy.codehaus.org jruby site http://jruby.codehaus.org ola bini’s blog http://olabini.blogspot.com/ charles nutter’s blog http://headius.blogspot.com/
  74. 74. ThoughtWorks resources jeff brown’s blog http://javajeff.blogspot.com/ graeme rocher’s blog http://graemerocher.blogspot.com/ aboutGroovy http://aboutGroovy.com venkat subramaniam’s blog http://www.agiledeveloper.com/blog/

Presentation of Neal Ford on JavaOne 2010

Views

Total views

1,794

On Slideshare

0

From embeds

0

Number of embeds

45

Actions

Downloads

16

Shares

0

Comments

0

Likes

0

×