Your SlideShare is downloading. ×
Comparing groovy and_j_ruby(neal_ford)
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

Comparing groovy and_j_ruby(neal_ford)

1,253
views

Published on

Presentation of Neal Ford on JavaOne 2010

Presentation of Neal Ford on JavaOne 2010

Published in: Technology

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

  • Be the first to like this

No Downloads
Views
Total Views
1,253
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
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. 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. housekeeping ask questions at the end (insane amount of material!) download slides from nealford.com download samples from github.com/nealford
  • 3. agenda: syntax closures eigenclass approaches meta-programming framework approach
  • 4. geek fu test:
  • 5. Groovy dynamicizes JRuby brings Ruby to the Java platform TM the Java platform TM
  • 6. differences & observations
  • 7. syntax
  • 8. sigils
  • 9. this.name vs @name
  • 10. auto-encapsulation?
  • 11. Perl !!!!!!!!!
  • 12. Ruby has some Perl-isms... ...with significant differences
  • 13. closures
  • 14. passing closures
  • 15. auto-blocks
  • 16. passing closures
  • 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. null is null ?. handles protected reference person?.address?.street
  • 19. nil is an instance of NilClass
  • 20. switch/case statement
  • 21. === isCase()
  • 22. “spread” operator
  • 23. “elvis” operator
  • 24. side effects of encapsulating Java™
  • 25. things added to Object
  • 26. supporting collections
  • 27. really? really!
  • 28. JRuby additions JRuby adds artifacts to “Rubify” Java™ ArrayList Fixnum ...but doesn’t add collection stuff to Object
  • 29. Groovy is (kind of) optionally typed
  • 30. search exists on Stack but not on ArrayList or List!
  • 31. interfaces & mixins
  • 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. be careful when implementing with a map: NullPointerException if you forget a method
  • 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. comparisons
  • 36. comparisons
  • 37. comparisons
  • 38. violating handshakes
  • 39. mixins in Groovy, interfaces in JRuby
  • 40. interfaces in JRuby?
  • 41. meta-programming
  • 42. mostly parity (functionally) very different implementations
  • 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. AST transformations
  • 45. implementation
  • 46. optional inclusion
  • 47. conditional method
  • 48. attributes
  • 49. hook methods
  • 50. sticky attributes private, protected, public
  • 51. eigenclass
  • 52. adding methods via proxies
  • 53. Groovy’s eigenclass
  • 54. framework approach
  • 55. encapsulate & extend
  • 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. abstraction layers via meta || dsl
  • 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. case study: builders
  • 60. GroovyObjectSupport BuilderSupport MarkupBuilder
  • 61. builder
  • 62. builder works via method_missing but what about this?
  • 63. the problem: how do you inherit from object... ...with inheriting from object?
  • 64. Jim Weirich’s 1.8 BlankSlate Object BasicObject BlankSlate Builder Recorder Builder Recorder Recorder 1.9 BasicObject
  • 65. different philosophies Groovy encapsulates and builds up Ruby either builds abstractions with dsl’s via meta-programming
  • 66. summary
  • 67. the good unparalleled Java™ integration willing to evolve the language the real JDK™ 2.0! building up from best-of-breed
  • 68. the bad fast changing at the core single runtime platform never spread out of the Java™ community framework approach?
  • 69. def name public String getName() public void setName(String name)
  • 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. 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. 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. 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. 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/