Your SlideShare is downloading. ×
A Tale of Two Rubies
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

A Tale of Two Rubies

276
views

Published on

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.

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
276
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
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. A Tale of Two Rubies...with apologies to Charles Dickens
  • 2. About MeJoshua BallancoName:
  • 3. About MeAnkara,TurkeyLocation:
  • 4. About MeBurnside DigitalEmployer:
  • 5. How many Rubyimplementations doyou use?
  • 6. Matz’s Ruby InterpreterJRubyRubiniusIronRubyMacRubyRubyMotionMagLev CardinalTopaz
  • 7. What impact doalternate Rubies haveon me?
  • 8. What aboutfragmentation?
  • 9. 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!
  • 10. What do you dowhen...ArgumentError: comparison of ActiveSupport::TimeWithZonewith ActiveSupport::TimeWithZone failed
  • 11. A Side Note onReading CodeRead Code
  • 12. A Side Note onReading CodeRead Code!
  • 13. A Side Note onReading CodeRead A Lot of Code
  • 14. A Side Note onReading CodeRead Twice as MuchCode asYou Write
  • 15. A Side Note onReading CodeRead Ten Times as MuchCode asYou Write
  • 16. A Side Note onReading CodeRead Code
  • 17. Let’s Go Code Diving!activesupport-3.2.13/lib/active_support/time_with_zone.rb
  • 18. Let’s Go Code Diving!
  • 19. Confused yet?When was the last time you calledTimeWithZone.new anyway???
  • 20. 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
  • 21. We Have to goDeeper!Read Code...and Comments
  • 22. So Far...• TimeWithZone initializes @utc to a Timeor DateTime• Comparison with <=> passes through“other” to @utc’s <=> operator
  • 23. But then......why?
  • 24. Remember This?
  • 25. It Gets Worse...
  • 26. Remember this?
  • 27. Oh,ActiveSupport...activesupport-3.2.13/lib/active_support/core_ext/date_time/calculations.rb
  • 28. Oh,ActiveSupport...activesupport-3.2.13/lib/active_support/core_ext/time/calculations.rb
  • 29. This isn’t a Rails Talk...Really...it’s not...
  • 30. Getting to the Heart ofthe Matter: JRuby• If “other” is a Time object, compare• Otherwise: nilsrc/org/jruby/RubyTime.java
  • 31. Getting to the Heart ofthe Matter: MRI
  • 32. 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
  • 33. So...Fix JRuby
  • 34. 1 Ruby Down1 To Go
  • 35. AlwaysBeCurious
  • 36. What Classes ReverseCompare Like This?• Time• ...• String• ...• That’s it!BUT!
  • 37. Oh, MRI...
  • 38. Break it down...If “other” is a string, do a string comparison(in the else clause...yay)
  • 39. Break it down...If “other” can not be convertedinto a string, return nil
  • 40. Break it down...If “other” also doesn’t have its owncomparison operator, return nil
  • 41. Break it down...If “other” does have its owncomparison operator, call it andreturn the negation of the resultBUT! ...
  • 42. Remember this?Uhh...
  • 43. Fun With PoorlySpecified Behavior...but I thought <=> only everreturned -1, 0, or 1?
  • 44. So...Fix MRI
  • 45. fin?Not quite...
  • 46. What about...Crap...
  • 47. Fun With MutualRecursion
  • 48. Fun With MutualRecursion
  • 49. Fun With MutualRecursion
  • 50. 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
  • 51. finQuestions?