RubyMotion: Under the Hood

RubyMotion:
Under the Hood
Inspired by Click and Clack

Monday, October 14, 2013
A brief introduction

Monday, October 14, 2013
About Me

Name: Joshua Ballanco
Monday, October 14, 2013
About Me

Employer: Burnside Digital
Monday, October 14, 2013
About Me

Location: Ankara, Turkey
Monday, October 14, 2013
A slightly longer
introduction

Monday, October 14, 2013
Before...

Monday, October 14, 2013
About Me

Employer: Patch
Monday, October 14, 2013
About Me

Location: New York City
Monday, October 14, 2013
Before that...

Monday, October 14, 2013
About Me

Employer: Apple
Monday, October 14, 2013
About Me

Location: Cupertino
Monday, October 14, 2013
Before that...

Monday, October 14, 2013
About Me

School: University of Miami
Monday, October 14, 2013
About Me

Location: Miami
Monday, October 14, 2013
A bit of history

Monday, October 14, 2013
In graduate school

Monday, October 14, 2013
In graduate school

Monday, October 14, 2013
At Apple... Retail

Monday, October 14, 2013
At Apple

Laurent Sansonetti

Monday, October 14, 2013
After Apple...

Monday, October 14, 2013
Episode VI - The Return
of The RubyMotion

Monday, October 14, 2013
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
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
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
What is MacRuby?
Ruby Syntax

Parser

Compiler

VM (sans GVL)

LLVM (with JIT)

Objective-C Runtime

Monday, October 14, 2013
Running a “something.rb” file
Ruby Syntax

Parser

Compiler

VM (sans GVL)

LLVM (with JIT)

Objective-C Runtime

Monday, October 14, 2013
Running a “something.rb” file
Ruby Syntax

Parser

Compiler

VM (sans GVL)

LLVM (with JIT)

Objective-C Runtime

Monday, October 14, 2013
Running a “something.rb” file
Ruby Syntax

Parser

Compiler

VM (sans GVL)

LLVM (with JIT)

Objective-C Runtime

Monday, October 14, 2013
AOT compiling “something.rb”
Ruby Syntax

Parser

Compiler

VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

LLVM

something.o
AOT compiling “something.rb”
Ruby Syntax

Parser

Compiler

VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

LLVM

something.o
Running an AOT compiled
“something.rb”
Parser

Compiler

VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
Running an AOT compiled
“something.rb”
Parser

Compiler

VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
Running an AOT compiled
“something.rb”
Parser

Compiler
LLVM
VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
Running an AOT compiled
“something.rb”
Parser

Compiler
LLVM
VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
Running an AOT compiled
“something.rb”
Parser

Compiler
LLVM
VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
What is RubyMotion?
• Descendent of MacRuby
• “Ruby, the Good Parts”
• Static Compiled
• Retain/release reference counting

Monday, October 14, 2013
Static compiling “something.rb”
Ruby Syntax

Parser

Compiler

VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

LLVM

something.o
Static compiling “something.rb”
Ruby Syntax

Parser

Compiler

VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

LLVM

something.o
Running a static compiled
“something.rb”
VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
Running a static compiled
“something.rb”
VM (sans GVL)

Objective-C Runtime

Monday, October 14, 2013

something.o
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
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
Garbage Collection

Monday, October 14, 2013
What happened to the
Garbage Collector?
It required extra threads, so we
had to kill it...

Monday, October 14, 2013
So RubyMotion Uses
ARC?
Yes...
Uh...no
...sorta?

Monday, October 14, 2013
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
ARC vs “ARC”
Isn’t the distinction
rather academic?
Probably...

Monday, October 14, 2013
“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
Debugging RubyMotion
• Remember, RubyMotion objects are
Objective-C objects...

• All the usual tricks are valid!

Monday, October 14, 2013
Let’s Play!

Monday, October 14, 2013
The Victim
app/app_delegate.rb

Monday, October 14, 2013
The Victim
app/app_delegate.rb

Monday, October 14, 2013
REPL Magic

Monday, October 14, 2013
REPL Magic

Monday, October 14, 2013
REPL Magic

Monday, October 14, 2013
REPL Magic

Monday, October 14, 2013
That’s cool...but can
you do it in a
debugger???

Monday, October 14, 2013
Debugger Wizardry

Monday, October 14, 2013
Debugger Wizardry

Monday, October 14, 2013
Debugger Wizardry

Monday, October 14, 2013
Debugger Wizardry

Monday, October 14, 2013
That’s CRAZY!
I know...but it’s fun!

Monday, October 14, 2013
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
Questions?
Joshua Ballanco
@manhattanmetric
https://github.com/jballanc

Monday, October 14, 2013
1 of 65

Recommended

Ruby Loves Dot Net by
Ruby Loves Dot NetRuby Loves Dot Net
Ruby Loves Dot NetIvan Porto Carrero
698 views37 slides
Intro To Ror by
Intro To RorIntro To Ror
Intro To Rorguest5dedf5
1K views24 slides
Playframework Hamburg Meetup #1 - Reactive persistence with Play 2 & postgres... by
Playframework Hamburg Meetup #1 - Reactive persistence with Play 2 & postgres...Playframework Hamburg Meetup #1 - Reactive persistence with Play 2 & postgres...
Playframework Hamburg Meetup #1 - Reactive persistence with Play 2 & postgres...Martin Grotzke
1.7K views7 slides
2009 07 21: Nested Attributes by
2009 07 21: Nested Attributes2009 07 21: Nested Attributes
2009 07 21: Nested AttributesWolfram Arnold
487 views10 slides
Intro to java by
Intro to javaIntro to java
Intro to javachrisramey
669 views34 slides
Intro for RoR by
Intro for RoRIntro for RoR
Intro for RoRVigneshwaran Seetharaman
511 views24 slides

More Related Content

Viewers also liked

Getting Your Ruby EGOT by
Getting Your Ruby EGOTGetting Your Ruby EGOT
Getting Your Ruby EGOTJoshua Ballanco
821 views66 slides
MacRuby for Fun and Profit by
MacRuby for Fun and ProfitMacRuby for Fun and Profit
MacRuby for Fun and ProfitJoshua Ballanco
1.2K views32 slides
A Tale of Two Rubies by
A Tale of Two RubiesA Tale of Two Rubies
A Tale of Two RubiesJoshua Ballanco
1.1K views51 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
Ruby memory model by
Ruby memory modelRuby memory model
Ruby memory modelHari Krishnan‎
988 views36 slides

Viewers also liked(6)

Similar to RubyMotion: Under the Hood

Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013 by
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013Mike Desjardins
3K views94 slides
Microservices and functional programming by
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programmingMichael Neale
24.9K views70 slides
Recommender Systems with Ruby (adding machine learning, statistics, etc) by
Recommender Systems with Ruby (adding machine learning, statistics, etc)Recommender Systems with Ruby (adding machine learning, statistics, etc)
Recommender Systems with Ruby (adding machine learning, statistics, etc)Marcel Caraciolo
44.6K views60 slides
Ruby off Rails by
Ruby off RailsRuby off Rails
Ruby off RailsCyril Ucron David
592 views29 slides
Contributing to WordPress by
Contributing to WordPressContributing to WordPress
Contributing to WordPressKonstantin Obenland
1.2K views30 slides
Enterprise rails hosting 3 ways to scale - 2011-10 by
Enterprise rails hosting   3 ways to scale - 2011-10 Enterprise rails hosting   3 ways to scale - 2011-10
Enterprise rails hosting 3 ways to scale - 2011-10 Avarteq
901 views199 slides

Similar to RubyMotion: Under the Hood(20)

Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013 by Mike Desjardins
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Rails Sojourn: One Man's Journey - Wicked Good Ruby Conference 2013
Mike Desjardins3K views
Microservices and functional programming by Michael Neale
Microservices and functional programmingMicroservices and functional programming
Microservices and functional programming
Michael Neale24.9K views
Recommender Systems with Ruby (adding machine learning, statistics, etc) by Marcel Caraciolo
Recommender Systems with Ruby (adding machine learning, statistics, etc)Recommender Systems with Ruby (adding machine learning, statistics, etc)
Recommender Systems with Ruby (adding machine learning, statistics, etc)
Marcel Caraciolo44.6K views
Enterprise rails hosting 3 ways to scale - 2011-10 by Avarteq
Enterprise rails hosting   3 ways to scale - 2011-10 Enterprise rails hosting   3 ways to scale - 2011-10
Enterprise rails hosting 3 ways to scale - 2011-10
Avarteq901 views
Latinoware Rails 2009 by Fabio Akita
Latinoware Rails 2009Latinoware Rails 2009
Latinoware Rails 2009
Fabio Akita539 views
Merged Automation Talk - Pete Carapetyan - Feb 2016 by petecarapetyan
Merged Automation Talk - Pete Carapetyan - Feb 2016 Merged Automation Talk - Pete Carapetyan - Feb 2016
Merged Automation Talk - Pete Carapetyan - Feb 2016
petecarapetyan188 views
Slaying Bugs with Gradle and Jenkins by David Kay
Slaying Bugs with Gradle and JenkinsSlaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and Jenkins
David Kay2.8K views
Cooking an Omelette with Chef by ctaintor
Cooking an Omelette with ChefCooking an Omelette with Chef
Cooking an Omelette with Chef
ctaintor1.1K views
Mastering ElasticSearch with Ruby and Tire by Luca Bonmassar
Mastering ElasticSearch with Ruby and TireMastering ElasticSearch with Ruby and Tire
Mastering ElasticSearch with Ruby and Tire
Luca Bonmassar7.8K views
Essential Test-Driven Development by TechWell
Essential Test-Driven DevelopmentEssential Test-Driven Development
Essential Test-Driven Development
TechWell244 views
Application Architectures in Grails by Peter Ledbrook
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in Grails
Peter Ledbrook9.4K views
RubyMotion: Put your Dreams in Motion with Ruby by Astrails
RubyMotion: Put your Dreams in Motion with RubyRubyMotion: Put your Dreams in Motion with Ruby
RubyMotion: Put your Dreams in Motion with Ruby
Astrails8.4K views
Oxente on Rails 2009 by Fabio Akita
Oxente on Rails 2009Oxente on Rails 2009
Oxente on Rails 2009
Fabio Akita904 views

Recently uploaded

SAP Automation Using Bar Code and FIORI.pdf by
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdfVirendra Rai, PMP
25 views38 slides
"Node.js Development in 2024: trends and tools", Nikita Galkin by
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin Fwdays
17 views38 slides
Info Session November 2023.pdf by
Info Session November 2023.pdfInfo Session November 2023.pdf
Info Session November 2023.pdfAleksandraKoprivica4
15 views15 slides
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc
72 views29 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
50 views15 slides
Network Source of Truth and Infrastructure as Code revisited by
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
32 views45 slides

Recently uploaded(20)

SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays17 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc72 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson126 views
The Forbidden VPN Secrets.pdf by Mariam Shaba
The Forbidden VPN Secrets.pdfThe Forbidden VPN Secrets.pdf
The Forbidden VPN Secrets.pdf
Mariam Shaba20 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn26 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...
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
"Running students' code in isolation. The hard way", Yurii Holiuk by Fwdays
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk
Fwdays24 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 Ruecker48 views

RubyMotion: Under the Hood