A Tale of Two Rubies

A Tale of Two Rubies
...with apologies to Charles Dickens
About Me
Joshua BallancoName:
About Me
Ankara,TurkeyLocation:
About Me
Burnside DigitalEmployer:
How many Ruby
implementations do
you use?
Matz’s Ruby Interpreter
JRuby
Rubinius
IronRuby
MacRuby
RubyMotion
MagLev Cardinal
Topaz
What impact do
alternate Rubies have
on me?
What about
fragmentation?
A Story...
Once upon a time there was a Rails app,
that needed to be ported to JRuby
• Ditch C-extensions
• Look for JRuby specific versions of gems
• Find a good app server
• Run your test suite!
What do you do
when...
ArgumentError: comparison of ActiveSupport::TimeWithZone
with ActiveSupport::TimeWithZone failed
A Side Note on
Reading Code
Read Code
A Side Note on
Reading Code
Read Code!
A Side Note on
Reading Code
Read A Lot of Code
A Side Note on
Reading Code
Read Twice as Much
Code asYou Write
A Side Note on
Reading Code
Read Ten Times as Much
Code asYou Write
A Side Note on
Reading Code
Read Code
Let’s Go Code Diving!
activesupport-3.2.13/lib/active_support/time_with_zone.rb
Let’s Go Code Diving!
Confused yet?
When was the last time you called
TimeWithZone.new anyway???
We Have to go
Deeper!
activesupport-3.2.13/lib/active_support/core_ext/time/zones.rb
activesupport-3.2.13/lib/active_support/core_ext/date_time/zones.rb
We Have to go
Deeper!
Read Code
...and Comments
So Far...
• TimeWithZone initializes @utc to a Time
or DateTime
• Comparison with <=> passes through
“other” to @utc’s <=> operator
But then...
...why?
Remember This?
It Gets Worse...
Remember this?
Oh,ActiveSupport...
activesupport-3.2.13/lib/active_support/core_ext/date_time/calculations.rb
Oh,ActiveSupport...
activesupport-3.2.13/lib/active_support/core_ext/time/calculations.rb
This isn’t a Rails Talk...
Really...it’s not...
Getting to the Heart of
the Matter: JRuby
• If “other” is a Time object, compare
• Otherwise: nil
src/org/jruby/RubyTime.java
Getting to the Heart of
the Matter: MRI
Getting to the Heart of
the Matter: MRI
• If “other” is a Time object, compare
• If not, call <=> on other, passing self as the
argument
• If that works, take the negation of the
result
• Otherwise: nil
So...Fix JRuby
1 Ruby Down
1 To Go
Always
Be
Curious
What Classes Reverse
Compare Like This?
• Time
• ...
• String
• ...
• That’s it!
BUT!
Oh, MRI...
Break it down...
If “other” is a string, do a string comparison
(in the else clause...yay)
Break it down...
If “other” can not be converted
into a string, return nil
Break it down...
If “other” also doesn’t have its own
comparison operator, return nil
Break it down...
If “other” does have its own
comparison operator, call it and
return the negation of the result
BUT! ...
Remember this?
Uhh...
Fun With Poorly
Specified Behavior
...but I thought <=> only ever
returned -1, 0, or 1?
So...Fix MRI
fin?
Not quite...
What about...
Crap...
Fun With Mutual
Recursion
Fun With Mutual
Recursion
Fun With Mutual
Recursion
The Moral
• When MRI was the only game in town,
whatever MRI did was “Ruby”
• Re-implementing “Ruby” allows us to
reconsider behaviors
• The key is communication and community
fin
Questions?
1 of 51

Recommended

Getting Your Ruby EGOT by
Getting Your Ruby EGOTGetting Your Ruby EGOT
Getting Your Ruby EGOTJoshua Ballanco
821 views66 slides
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ... by
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...tdc-globalcode
33 views19 slides
Meta Programming in Ruby - Code Camp 2010 by
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010ssoroka
1.6K views366 slides
Types are eating the world by
Types are eating the worldTypes are eating the world
Types are eating the worldFangda Wang
78 views53 slides
MacRuby: What is it? and why should you care? by
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?Joshua Ballanco
1.3K views30 slides
There and Back Again by
There and Back AgainThere and Back Again
There and Back AgainJoshua Ballanco
993 views77 slides

More Related Content

Similar to A Tale of Two Rubies

JRuby: The Hard Parts by
JRuby: The Hard PartsJRuby: The Hard Parts
JRuby: The Hard PartsCharles Nutter
2.8K views71 slides
Ruby for C#-ers (ScanDevConf 2010) by
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Thomas Lundström
888 views27 slides
Not Everything is an Object - Rocksolid Tour 2013 by
Not Everything is an Object  - Rocksolid Tour 2013Not Everything is an Object  - Rocksolid Tour 2013
Not Everything is an Object - Rocksolid Tour 2013Gary Short
759 views34 slides
Ruby On Rails pizza training by
Ruby On Rails pizza trainingRuby On Rails pizza training
Ruby On Rails pizza trainingdavid_alphen
2.5K views54 slides
Euruko 2012 - JRuby by
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRubyCharles Nutter
2.2K views67 slides
Js bad_ by
 Js bad_ Js bad_
Js bad_Rob Robbins
249 views9 slides

Similar to A Tale of Two Rubies(20)

Not Everything is an Object - Rocksolid Tour 2013 by Gary Short
Not Everything is an Object  - Rocksolid Tour 2013Not Everything is an Object  - Rocksolid Tour 2013
Not Everything is an Object - Rocksolid Tour 2013
Gary Short759 views
Ruby On Rails pizza training by david_alphen
Ruby On Rails pizza trainingRuby On Rails pizza training
Ruby On Rails pizza training
david_alphen2.5K views
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point) by Darshan Karandikar
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
JRuby on Rails - RoR's Simplicity Meets Java's Class (a case in point)
Darshan Karandikar1.2K views
JRuby - The Best of Java and Ruby by Evgeny Rahman
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and Ruby
Evgeny Rahman1K views
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ... by JAX London
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
JAX London1.7K views
Understanding Typing. Understanding Ruby. by Justin Lin
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.
Justin Lin4.5K views
Feels Like Ruby - Ruby Kaigi 2010 by Sarah Mei
Feels Like Ruby - Ruby Kaigi 2010Feels Like Ruby - Ruby Kaigi 2010
Feels Like Ruby - Ruby Kaigi 2010
Sarah Mei1.2K views
RingoJS: Server-Side Javascript When Only Java Will Do by Darren Cruse
RingoJS:  Server-Side Javascript When Only Java Will DoRingoJS:  Server-Side Javascript When Only Java Will Do
RingoJS: Server-Side Javascript When Only Java Will Do
Darren Cruse2.3K views
Adventures of java developer in ruby world by Orest Ivasiv
Adventures of java developer in ruby worldAdventures of java developer in ruby world
Adventures of java developer in ruby world
Orest Ivasiv2.1K views
Why i love ruby than x by Samnang Chhun
Why i love ruby than xWhy i love ruby than x
Why i love ruby than x
Samnang Chhun1.1K views
JRuby: What's Different (RORO Melbourne October 2011) by Charles Nutter
JRuby: What's Different (RORO Melbourne October 2011)JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)
Charles Nutter610 views
Rails Is From Mars Ruby Is From Venus Presentation 1 by railsconf
Rails Is From Mars  Ruby Is From Venus Presentation 1Rails Is From Mars  Ruby Is From Venus Presentation 1
Rails Is From Mars Ruby Is From Venus Presentation 1
railsconf935 views

Recently uploaded

Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...ShapeBlue
173 views15 slides
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
54 views69 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
147 views23 slides
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...ShapeBlue
126 views10 slides
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesShapeBlue
252 views15 slides
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...ShapeBlue
139 views29 slides

Recently uploaded(20)

Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue173 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker54 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue147 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue126 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue252 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue139 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue206 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue184 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... by ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue132 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue203 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu423 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue138 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li85 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue159 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue180 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue222 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10123 views

A Tale of Two Rubies