• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
A Tale of Two Rubies
 

A Tale of Two Rubies

on

  • 391 views

Slides from the talk "A Tale of Two Rubies" that I presented at the RuLu 2013 conference.

Slides from the talk "A Tale of Two Rubies" that I presented at the RuLu 2013 conference.

Statistics

Views

Total Views
391
Views on SlideShare
357
Embed Views
34

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 34

https://twitter.com 34

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    A Tale of Two Rubies A Tale of Two Rubies Presentation Transcript

    • A Tale of Two Rubies...with apologies to Charles Dickens
    • About MeJoshua BallancoName:
    • About MeAnkara,TurkeyLocation:
    • About MeBurnside DigitalEmployer:
    • How many Rubyimplementations doyou use?
    • Matz’s Ruby InterpreterJRubyRubiniusIronRubyMacRubyRubyMotionMagLev CardinalTopaz
    • What impact doalternate Rubies haveon me?
    • What aboutfragmentation?
    • 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 dowhen...ArgumentError: comparison of ActiveSupport::TimeWithZonewith ActiveSupport::TimeWithZone failed
    • A Side Note onReading CodeRead Code
    • A Side Note onReading CodeRead Code!
    • A Side Note onReading CodeRead A Lot of Code
    • A Side Note onReading CodeRead Twice as MuchCode asYou Write
    • A Side Note onReading CodeRead Ten Times as MuchCode asYou Write
    • A Side Note onReading CodeRead 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 calledTimeWithZone.new anyway???
    • We Have to goDeeper!activesupport-3.2.13/lib/active_support/core_ext/time/zones.rbactivesupport-3.2.13/lib/active_support/core_ext/date_time/zones.rb
    • We Have to goDeeper!Read Code...and Comments
    • So Far...• TimeWithZone initializes @utc to a Timeor 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 ofthe Matter: JRuby• If “other” is a Time object, compare• Otherwise: nilsrc/org/jruby/RubyTime.java
    • Getting to the Heart ofthe Matter: MRI
    • Getting to the Heart ofthe Matter: MRI• If “other” is a Time object, compare• If not, call <=> on other, passing self as theargument• If that works, take the negation of theresult• Otherwise: nil
    • So...Fix JRuby
    • 1 Ruby Down1 To Go
    • AlwaysBeCurious
    • What Classes ReverseCompare 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 convertedinto a string, return nil
    • Break it down...If “other” also doesn’t have its owncomparison operator, return nil
    • Break it down...If “other” does have its owncomparison operator, call it andreturn the negation of the resultBUT! ...
    • Remember this?Uhh...
    • Fun With PoorlySpecified Behavior...but I thought <=> only everreturned -1, 0, or 1?
    • So...Fix MRI
    • fin?Not quite...
    • What about...Crap...
    • Fun With MutualRecursion
    • Fun With MutualRecursion
    • Fun With MutualRecursion
    • The Moral• When MRI was the only game in town,whatever MRI did was “Ruby”• Re-implementing “Ruby” allows us toreconsider behaviors• The key is communication and community
    • finQuestions?