Slide 1

Slide 1 text

MobiRuby iOS + Ruby = Super Awesome!! Thursday, February 14, 13

Slide 2

Slide 2 text

Hi! I’m @masuidrive. • Yuichiro MASUI - Ichi • Open source developer, Ruby fun • Pukiwiki, Ruby on Rails tutorial movie in Japanese, IKEA hacker • Furo-grammer (Coding in hot tub) • FrogApps, Inc. CTO // ex-Appcelerati Thursday, February 14, 13

Slide 3

Slide 3 text

Hi! I’m @masuidrive. • Yuichiro MASUI - Ichi • Open source developer, Ruby fun • Pukiwiki, Ruby on Rails tutorial movie in Japanese, IKEA hacker • Furo-grammer (Coding in hot tub) • FrogApps, Inc. CTO // ex-Appcelerati ϛΠϧ Thursday, February 14, 13

Slide 4

Slide 4 text

mruby Thursday, February 14, 13

Slide 5

Slide 5 text

mruby • Ruby for less resources • ISO/JIS compliant • CRuby subset. Not included File, Socket, Thread and more ext libraries • OS / CPU Independent • Not required POSIX, only C99 Thursday, February 14, 13

Slide 6

Slide 6 text

Configurable • Drop off unnecessary features • Parser / Compiler • Struct, Time, Math, STDIO, Regexp, sprintf • Table algorithm - hash or list • NaN Boxing Thursday, February 14, 13

Slide 7

Slide 7 text

mruby target • Embedded • Digital Appliance • Game console • Vendor machine • Bundle with applications Thursday, February 14, 13

Slide 8

Slide 8 text

mruby internals • VM structure - Multi VM instance • No C global variable • Generational incremental GC (Mark&Sweep) • Not thread safe • Build system build on CRuby Thursday, February 14, 13

Slide 9

Slide 9 text

development • Spring 2010 - Subsidy • Matz, some companies and colleges • April 22, 2012 - Publish to GitHub • mruby got some contributors Thursday, February 14, 13

Slide 10

Slide 10 text

mrbgems • Daniel (@bovi) created extension package feature at end of Nov 2012. • Easy to install from GitHub • Supported cross build • Already provided 40+ gems Thursday, February 14, 13

Slide 11

Slide 11 text

mrbgems • Daniel (@bovi) created extension package feature at end of Nov 2012. • Easy to install from GitHub • Supported cross build • Already provided 40+ gems Thursday, February 14, 13

Slide 12

Slide 12 text

Thursday, February 14, 13

Slide 13

Slide 13 text

Thursday, February 14, 13

Slide 14

Slide 14 text

When will you release RiteVM? I want to run it on iOS/ Android . It’s mruby. I need more time to make public (probably June) Should I give you access to private repos? Yes! I want to try it! What’s your github account? Thursday, February 14, 13

Slide 15

Slide 15 text

Thursday, February 14, 13

Slide 16

Slide 16 text

What’s MobiRuby? • iOS app development kit on mruby • MIT license • Can access native functions • Have plan for Android version • Already released MobiRuby based app • Search “mobiruby” in AppStore on iOS Thursday, February 14, 13

Slide 17

Slide 17 text

Vision • Provide Ruby power to Mobile devices • Meta programming is most important Ruby power Thursday, February 14, 13

Slide 18

Slide 18 text

Hello world \ 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 urlstr = "http://mobiruby.org" url = Cocoa::NSURL._URLWithString(urlstr) app._openURL url end end end alert = Cocoa::MyAlertView._alloc._initWithTitle "Hello", :message, "I am MobiRuby", :delegate, nil, :cancelButtonTitle, "I know!", :otherButtonTitles, "What's?", nil alert._setDelegate alert alert._show Thursday, February 14, 13

Slide 19

Slide 19 text

Hello world \ 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 urlstr = "http://mobiruby.org" url = Cocoa::NSURL._URLWithString(urlstr) app._openURL url end end end alert = Cocoa::MyAlertView._alloc._initWithTitle "Hello", :message, "I am MobiRuby", :delegate, nil, :cancelButtonTitle, "I know!", :otherButtonTitles, "What's?", nil alert._setDelegate alert alert._show Thursday, February 14, 13

Slide 20

Slide 20 text

class Cocoa::MyAlertView < Cocoa::UIAlertView define C::Void, :alertView, Cocoa::Object, :clickedButtonAtIndex, C::Int do |me, idx| if idx.to_i == 1 app = Cocoa::UIApplication._sharedApplica urlstr = "http://mobiruby.org" url = Cocoa::NSURL._URLWithString(urlstr) app._openURL url end end end class Cocoa::MyAlertView < Cocoa::UIAlertView define C::Void, :alertView, Cocoa::Object, :clickedButtonAtIndex, C::Int do |me, idx| if idx.to_i == 1 app = Cocoa::UIApplication._sharedApplica urlstr = "http://mobiruby.org" url = Cocoa::NSURL._URLWithString(urlstr) app._openURL url end end end Hello world - 1st half Thursday, February 14, 13

Slide 21

Slide 21 text

class Cocoa::MyAlertView < Cocoa::UIAlertView define C::Void, :alertView, Cocoa::Object, :clickedButtonAtIndex, C::Int do |me, idx| if idx.to_i == 1 app = Cocoa::UIApplication._sharedApplica urlstr = "http://mobiruby.org" url = Cocoa::NSURL._URLWithString(urlstr) app._openURL url end end end Hello world - 1st half class Cocoa::MyAlertView < Cocoa::UIAlertView Thursday, February 14, 13

Slide 22

Slide 22 text

class Cocoa::MyAlertView < Cocoa::UIAlertView define C::Void, :alertView, Cocoa::Object, :clickedButtonAtIndex, C::Int do |me, idx| if idx.to_i == 1 app = Cocoa::UIApplication._sharedApplica urlstr = "http://mobiruby.org" url = Cocoa::NSURL._URLWithString(urlstr) app._openURL url end end end define C::Void, :alertView, Cocoa::Object, :clickedButtonAtIndex, C::Int do |me, idx| Hello world - 1st half Thursday, February 14, 13

Slide 23

Slide 23 text

Hello world - 2nd half \ alert = Cocoa::MyAlertView._alloc. _initWithTitle "Hello", :message, "I am MobiRuby", :delegate, nil, :cancelButtonTitle, "I know!", :otherButtonTitles, "What's?", nil alert._setDelegate alert alert._show alert = Cocoa::MyAlertView._alloc. _initWithTitle "Hello", :message, "I am MobiRuby", :delegate, nil, :cancelButtonTitle, "I know!", :otherButtonTitles, "What's?", nil alert._setDelegate alert alert._show Thursday, February 14, 13

Slide 24

Slide 24 text

Hello world - 2nd half \ alert = Cocoa::MyAlertView._alloc. _initWithTitle "Hello", :message, "I am MobiRuby", :delegate, nil, :cancelButtonTitle, "I know!", :otherButtonTitles, "What's?", nil alert._setDelegate alert alert._show alert = Cocoa::MyAlertView._alloc. _initWithTitle "Hello", :message, "I am MobiRuby", :delegate, nil, :cancelButtonTitle, "I know!", :otherButtonTitles, "What's?", nil alert._setDelegate alert alert._show Thursday, February 14, 13

Slide 25

Slide 25 text

Next step \ class MyAlertView < MobiRuby::AlertView title "Hello" message "I am MobiRuby" cancelButton "I know!" do end button "What's?" do openURL "http://mobiruby.org" end end alert = MyAlertView.new alert.show Thursday, February 14, 13

Slide 26

Slide 26 text

MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa mobiruby- common mobiruby- ios Thursday, February 14, 13

Slide 27

Slide 27 text

MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa mobiruby- common mobiruby- ios Thursday, February 14, 13

Slide 28

Slide 28 text

MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa mobiruby- common mobiruby- ios Thursday, February 14, 13

Slide 29

Slide 29 text

mruby-cfunc • C function bridge for mruby • Call C based function directly • Based on libFFI • Same as Ruby/DL library on CRuby Thursday, February 14, 13

Slide 30

Slide 30 text

mruby-cfunc str = "STRING" CFunc::call(CFunc::Void, "puts", str) STRING Thursday, February 14, 13

Slide 31

Slide 31 text

mruby-cfunc str = "STRING" ptr = CFunc::Pointer.malloc(7) result_ptr = CFunc::call(CFunc::Pointer, "strcpy", ptr, str) ptr.to_s -> “STRING” Thursday, February 14, 13

Slide 32

Slide 32 text

mruby-cfunc \ class TestStruct < CFunc::Struct define CFunc::SInt8, :x, CFunc::SInt16, :y end test = TestStruct.new test[:x] = 10 Thursday, February 14, 13

Slide 33

Slide 33 text

MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa mobiruby- common mobiruby- ios Thursday, February 14, 13

Slide 34

Slide 34 text

mruby-cocoa • Cocoa bridge for mruby • Use Cocoa functions transparently • Based on mruby-cfunc and Cocoa runtime • Manipulate Cocoa objects • Create class/instance, inherit existing classes • Garbage collection Thursday, February 14, 13

Slide 35

Slide 35 text

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 Thursday, February 14, 13

Slide 36

Slide 36 text

Memory management • Objective-C - Reference count • mruby - Mark & Sweep • Swizzled Objective-C “release” method • awful performance bottleneck Thursday, February 14, 13

Slide 37

Slide 37 text

MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa mobiruby- common mobiruby- ios Thursday, February 14, 13

Slide 38

Slide 38 text

mobiruby-common • Will be common utilities with Android ver. • require method • Some POSIX based functions Thursday, February 14, 13

Slide 39

Slide 39 text

MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa mobiruby- common mobiruby- ios Thursday, February 14, 13

Slide 40

Slide 40 text

mobiruby-ios • iOS specific utilities • Bootstrap • Xcode integration • Wrapped classes Thursday, February 14, 13

Slide 41

Slide 41 text

Wrapped APIs \ class MyAlertView < MobiRuby::AlertView title "Hello" message "I am MobiRuby" cancelButton "I know!" do end button "What's?" do openURL "http://mobiruby.org" end end alert = MyAlertView.new alert.show Thursday, February 14, 13

Slide 42

Slide 42 text

Road map • Finished building Cocoa bridge • Fix bugs, Improvement • Packaging • Documentation • Build wrapped APIs Thursday, February 14, 13

Slide 43

Slide 43 text

Road map • Finished building Cocoa bridge • Fix bugs, Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Q1 2013 Thursday, February 14, 13

Slide 44

Slide 44 text

Road map • Finished building Cocoa bridge • Fix bugs, Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Q1 2013 Thursday, February 14, 13

Slide 45

Slide 45 text

Current status • Already MobiRuby based app is in AppStore • Finally released alpha 1 • Can call almost iOS native functions • Writing test codes • It's only for iOS and mruby hackers Thursday, February 14, 13

Slide 46

Slide 46 text

Pros. • Ruby power • Based on Matz implemented Ruby • mrbgems • MIT license • Compact (~4000 lines) Thursday, February 14, 13

Slide 47

Slide 47 text

Cons. • Unstable • Less classes / functions • Don't have debugging feature • Need to understand iOS and Cocoa Thursday, February 14, 13

Slide 48

Slide 48 text

Action! • Provide Ruby Power to the world • Create worldwide portfolio • Talk it at one or two foreign conferences Thursday, February 14, 13

Slide 49

Slide 49 text

Questions? • If you have more questions, please tweet to @mobiruby or post to github issues. • http://twitter.com/mobiruby • http://github.com/mobiruby Thursday, February 14, 13

Slide 50

Slide 50 text

Thank you • Logo design: Maylis Agniel • English review: @tenderlove and ebi-chan • http://mobiruby.org • http://github.com/mobiruby • http://twitter.com/mobiruby • http://fb.me/mobiruby Thursday, February 14, 13