RubyMotion: Under the Hood

1,562 views

Published on

Slides from the talk "RubyMotion: Under the Hood" presented at the Wicked Good Ruby Conference in 2013.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,562
On SlideShare
0
From Embeds
0
Number of Embeds
160
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

RubyMotion: Under the Hood

  1. 1. RubyMotion: Under the Hood Inspired by Click and Clack Monday, October 14, 2013
  2. 2. A brief introduction Monday, October 14, 2013
  3. 3. About Me Name: Joshua Ballanco Monday, October 14, 2013
  4. 4. About Me Employer: Burnside Digital Monday, October 14, 2013
  5. 5. About Me Location: Ankara, Turkey Monday, October 14, 2013
  6. 6. A slightly longer introduction Monday, October 14, 2013
  7. 7. Before... Monday, October 14, 2013
  8. 8. About Me Employer: Patch Monday, October 14, 2013
  9. 9. About Me Location: New York City Monday, October 14, 2013
  10. 10. Before that... Monday, October 14, 2013
  11. 11. About Me Employer: Apple Monday, October 14, 2013
  12. 12. About Me Location: Cupertino Monday, October 14, 2013
  13. 13. Before that... Monday, October 14, 2013
  14. 14. About Me School: University of Miami Monday, October 14, 2013
  15. 15. About Me Location: Miami Monday, October 14, 2013
  16. 16. A bit of history Monday, October 14, 2013
  17. 17. In graduate school Monday, October 14, 2013
  18. 18. In graduate school Monday, October 14, 2013
  19. 19. At Apple... Retail Monday, October 14, 2013
  20. 20. At Apple Laurent Sansonetti Monday, October 14, 2013
  21. 21. After Apple... Monday, October 14, 2013
  22. 22. Episode VI - The Return of The RubyMotion Monday, October 14, 2013
  23. 23. What is RubyMotion? • Use Ruby to build apps for iOS and OS X • Native apps • Interface directly with Obj-C libraries • CLI-based build system Monday, October 14, 2013
  24. 24. What is RubyMotion? • RubyMotion: http://www.rubymotion.com/ • MotionCasts: http://motioncasts.tv/ • RubyMotion Wrappers: ! http://rubymotion-wrappers.com/ • ...and lot’s more Monday, October 14, 2013
  25. 25. What is MacRuby? • Intended to be the implementation of Ruby 2.0 for OS X • Target RubySpec compliance • JIT or AOT Compiled • Uses libauto for Garbage Collection Monday, October 14, 2013
  26. 26. What is MacRuby? Ruby Syntax Parser Compiler VM (sans GVL) LLVM (with JIT) Objective-C Runtime Monday, October 14, 2013
  27. 27. Running a “something.rb” file Ruby Syntax Parser Compiler VM (sans GVL) LLVM (with JIT) Objective-C Runtime Monday, October 14, 2013
  28. 28. Running a “something.rb” file Ruby Syntax Parser Compiler VM (sans GVL) LLVM (with JIT) Objective-C Runtime Monday, October 14, 2013
  29. 29. Running a “something.rb” file Ruby Syntax Parser Compiler VM (sans GVL) LLVM (with JIT) Objective-C Runtime Monday, October 14, 2013
  30. 30. AOT compiling “something.rb” Ruby Syntax Parser Compiler VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 LLVM something.o
  31. 31. AOT compiling “something.rb” Ruby Syntax Parser Compiler VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 LLVM something.o
  32. 32. Running an AOT compiled “something.rb” Parser Compiler VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  33. 33. Running an AOT compiled “something.rb” Parser Compiler VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  34. 34. Running an AOT compiled “something.rb” Parser Compiler LLVM VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  35. 35. Running an AOT compiled “something.rb” Parser Compiler LLVM VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  36. 36. Running an AOT compiled “something.rb” Parser Compiler LLVM VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  37. 37. What is RubyMotion? • Descendent of MacRuby • “Ruby, the Good Parts” • Static Compiled • Retain/release reference counting Monday, October 14, 2013
  38. 38. Static compiling “something.rb” Ruby Syntax Parser Compiler VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 LLVM something.o
  39. 39. Static compiling “something.rb” Ruby Syntax Parser Compiler VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 LLVM something.o
  40. 40. Running a static compiled “something.rb” VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  41. 41. Running a static compiled “something.rb” VM (sans GVL) Objective-C Runtime Monday, October 14, 2013 something.o
  42. 42. Why must we statically compile? • On OS X • Compile writes code to a memory page • Runtime runs the code from that memory page Monday, October 14, 2013
  43. 43. Why must we statically compile? • On iOS Memory pages must be writable or executable, NOT BOTH! • • • Monday, October 14, 2013 • OS prohibits runtime compilation Apple prohibits interpreting arbitrary scripts ...but you wouldn’t want an interpreter anyway
  44. 44. Garbage Collection Monday, October 14, 2013
  45. 45. What happened to the Garbage Collector? It required extra threads, so we had to kill it... Monday, October 14, 2013
  46. 46. So RubyMotion Uses ARC? Yes... Uh...no ...sorta? Monday, October 14, 2013
  47. 47. ARC vs “ARC” • Objective-C’s ARC modifies your code before compilation • RubyMotion VM knows when retain and/or release should be called...your code is not touched Monday, October 14, 2013
  48. 48. ARC vs “ARC” Isn’t the distinction rather academic? Probably... Monday, October 14, 2013
  49. 49. “ARC” Caveats • Collection happens when the autorelease pool drains • Need to be careful with tight loops that generate many objects • Use “autorelease do...end” • Detects almost all cycles • Use WeakRefs if cycles become problematic Monday, October 14, 2013
  50. 50. Debugging RubyMotion • Remember, RubyMotion objects are Objective-C objects... • All the usual tricks are valid! Monday, October 14, 2013
  51. 51. Let’s Play! Monday, October 14, 2013
  52. 52. The Victim app/app_delegate.rb Monday, October 14, 2013
  53. 53. The Victim app/app_delegate.rb Monday, October 14, 2013
  54. 54. REPL Magic Monday, October 14, 2013
  55. 55. REPL Magic Monday, October 14, 2013
  56. 56. REPL Magic Monday, October 14, 2013
  57. 57. REPL Magic Monday, October 14, 2013
  58. 58. That’s cool...but can you do it in a debugger??? Monday, October 14, 2013
  59. 59. Debugger Wizardry Monday, October 14, 2013
  60. 60. Debugger Wizardry Monday, October 14, 2013
  61. 61. Debugger Wizardry Monday, October 14, 2013
  62. 62. Debugger Wizardry Monday, October 14, 2013
  63. 63. That’s CRAZY! I know...but it’s fun! Monday, October 14, 2013
  64. 64. Debugging RubyMotion • Helper methods “pro” and “pri” • http://www.rubymotion.com/developercenter/articles/debugging/ • Watch for more/better tooling to come... Monday, October 14, 2013
  65. 65. Questions? Joshua Ballanco @manhattanmetric https://github.com/jballanc Monday, October 14, 2013

×