SlideShare a Scribd company logo
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
housekeeping
ask questions at the end
(insane amount of material!)


download slides from
nealford.com



download samples from github.com/nealford
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
                             TM
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 object...

except null

in JRuby, everything is an object.
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


                                             Fixnum
    ...but doesn’t add collection stuff to Object
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” interfaces via closures using as
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 of specialization

a way to collect functionality
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, attr_writer,
   attr_accessor

   include


   private, protected, public
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 simplify and humanize them

encapsulate, then build up
abstraction
layers
via
meta || dsl
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
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
Recorder          Builder
                  Recorder
                  Recorder




           1.9
                  BasicObject
different philosophies

Groovy encapsulates and builds up

Ruby either builds

   abstractions with dsl’s

   via meta-programming
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 cross platform, for the new definition of
platform

interpreted, then jit-ted
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
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
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/
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/

More Related Content

Similar to Comparing groovy and_j_ruby(neal_ford)

Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
elliando dias
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
Yuri Visser
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
Thoughtworks
 
Feelin' Groovy: An Afternoon of Reflexive Metaprogramming
Feelin' Groovy: An Afternoon of Reflexive MetaprogrammingFeelin' Groovy: An Afternoon of Reflexive Metaprogramming
Feelin' Groovy: An Afternoon of Reflexive Metaprogramming
Matt Stine
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
David Keener
 
Your java script library
Your java script libraryYour java script library
Your java script library
jasfog
 
Groovy And Grails
Groovy And GrailsGroovy And Grails
Groovy And Grails
William Grosso
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
elliando dias
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
David Beazley (Dabeaz LLC)
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
mbeizer
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
Will Green
 
Groovy and Grails
Groovy and GrailsGroovy and Grails
Groovy and Grails
GiltTech
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
mzgubin
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
mzgubin
 
Raphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberRaphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React Fiber
React Conf Brasil
 
Design Pattern Automation
Design Pattern AutomationDesign Pattern Automation
Design Pattern Automation
PostSharp Technologies
 
Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Javascript Apps at Build Artifacts
Javascript Apps at Build ArtifactsJavascript Apps at Build Artifacts
Javascript Apps at Build Artifacts
Clay Smith
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
Kevin Whinnery
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
Kevin Whinnery
 

Similar to Comparing groovy and_j_ruby(neal_ford) (20)

Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Neal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary ArchitectureNeal Ford Emergent Design And Evolutionary Architecture
Neal Ford Emergent Design And Evolutionary Architecture
 
Feelin' Groovy: An Afternoon of Reflexive Metaprogramming
Feelin' Groovy: An Afternoon of Reflexive MetaprogrammingFeelin' Groovy: An Afternoon of Reflexive Metaprogramming
Feelin' Groovy: An Afternoon of Reflexive Metaprogramming
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 
Your java script library
Your java script libraryYour java script library
Your java script library
 
Groovy And Grails
Groovy And GrailsGroovy And Grails
Groovy And Grails
 
Dynamic Languages on the JVM
Dynamic Languages on the JVMDynamic Languages on the JVM
Dynamic Languages on the JVM
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
IronRuby for the Rubyist
IronRuby for the RubyistIronRuby for the Rubyist
IronRuby for the Rubyist
 
Groovy and Grails
Groovy and GrailsGroovy and Grails
Groovy and Grails
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
 
Raphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React FiberRaphael Amorim - Scrating React Fiber
Raphael Amorim - Scrating React Fiber
 
Design Pattern Automation
Design Pattern AutomationDesign Pattern Automation
Design Pattern Automation
 
Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Javascript Apps at Build Artifacts
Javascript Apps at Build ArtifactsJavascript Apps at Build Artifacts
Javascript Apps at Build Artifacts
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 
Write Better JavaScript
Write Better JavaScriptWrite Better JavaScript
Write Better JavaScript
 

Recently uploaded

AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Neo4j
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 

Recently uploaded (20)

AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid ResearchHarnessing the Power of NLP and Knowledge Graphs for Opioid Research
Harnessing the Power of NLP and Knowledge Graphs for Opioid Research
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 

Comparing groovy and_j_ruby(neal_ford)