Hi! I’m masuidrive. • Yuichiro MASUI (masuidrive, Ichi) • Open source developer, Ruby fun • FrogApps, Inc. ex-Appcelerati • Pukiwiki, Ruby on Rails tutorial movie in Japanese, IKEA hacker • Furo-grammer (Coding in hot tub)
mruby • New implementation of Ruby for embedding • Built by dad Matz • Less memory and storage • Not required POSIX, only C99 • Simple spec, Not included File, Socket, Thread and ext libraries
Bridge Cocoa runtime • Objective-C has powerful runtime features • Create and modify class dynamically • ObjC class <- Ruby class <- ObjC class • ObjC value interconverted with Ruby value • Supported delegate and blocks
Multi-threading • MobiRuby does not support threads • Because mruby does not support threads • I have not touched them yet • Need to implement multi VM instead of thread
Your code class
Cocoa::MyAlertView
<
Cocoa::UIAlertView
define
C::Void,
:alertView,
Cocoa::Object,
:clickedButtonAtIndex,
C::Int
do
|me,
index|
if
index.to_i
==
1
app
=
Cocoa::UIApplication._sharedApplication
str
=
"http://mobiruby.org"
url
=
Cocoa::NSURL._URLWithString(str)
app._openURL
url
end
end end
Progress in Sept 2012 • Already MobiRuby based app is in AppStore • Finally released alpha 1 • It's only for iOS and mruby hackers • Need deeply understanding Cocoa runtime, mruby, Garbage collection
Current tasks • Fixed crashing bugs and memory leaks • Test Test Test!!! • Support `long` and `long long`, define Cocoa property and more... • Circular reference • mruby stability
FAQ • Can I use RubyGems? • Can I use meta programming? e.g., define_method, eval • Can I use exists Cocoa libraries? • Can I define new method to exist Cocoa class? • What version iOS does it support?
Can I use meta programming? e.g., define_method, eval • Yes, mruby supports almost all dynamic programming features. • But MobiRuby doesn’t support eval. mruby can remove compiler. (it’s for Apple)
Can I define new method to exist Cocoa class? • Yes, You can define new methods from Ruby • You can inherit exists Cocoa and create new class from Ruby