MobiRuby - RubyConf 2012

0ec58a040e1e4e959c8566484b4bba19?s=47 Yuichiro MASUI
November 03, 2012
180

MobiRuby - RubyConf 2012

* RubyConf 2012
* 3rd November 2012 in Denver
* http://rubyconf2012.busyconf.com/schedule/full
* Speaker: Yuichiro MASUI
* Reviewer: Aaron Petterson and ebi-chan.

* https://github.com/masuidrive/mobiruby-rubyconf2012 has presentation notes.

0ec58a040e1e4e959c8566484b4bba19?s=128

Yuichiro MASUI

November 03, 2012
Tweet

Transcript

  1. MobiRuby iOS + Ruby = Super Awesome!! Friday, November 2,

    12
  2. 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 Friday, November 2, 12
  3. What’s MobiRuby? • iOS app development environment on mruby •

    MIT license • Can access native functions • Have plan for Android version • Already released MobiRuby based app • Search “mobiruby” in AppStore on iOS Friday, November 2, 12
  4. mruby • New implementation of Ruby for embedding • Built

    by dad Matz • Less memory and storage • Not required POSIX, only C99 • CRuby subsetNot included File, Socket, Thread and more ext libraries Friday, November 2, 12
  5. Vision • MobiRuby provides Ruby power to Mobile devices •

    Meta programming is most important Ruby power Friday, November 2, 12
  6. 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 Friday, November 2, 12
  7. 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 Friday, November 2, 12
  8. 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 Friday, November 2, 12
  9. 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 Hello world - 1st half Friday, November 2, 12
  10. 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 Friday, November 2, 12
  11. 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 Friday, November 2, 12
  12. 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 Friday, November 2, 12
  13. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Friday, November 2, 12
  14. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Friday, November 2, 12
  15. Will you release RiteVM soon? 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? Friday, November 2, 12
  16. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Friday, November 2, 12
  17. mruby-cfunc • C function bridge for mruby • Call C

    based function directly • Based on libFFI • Same as Ruby/DL library on CRuby Friday, November 2, 12
  18. mruby-cfunc str  =  "STRING" CFunc::call(CFunc::Void,  "puts",  str) STRING Friday, November

    2, 12
  19. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Friday, November 2, 12
  20. 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 Friday, November 2, 12
  21. 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 Friday, November 2, 12
  22. Memory management • Objective-C - Reference count • mruby -

    Mark & Sweep • Swizzled Objective-C release method • awful performance bottleneck Friday, November 2, 12
  23. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Friday, November 2, 12
  24. mobiruby-common • Will be common utilities with Android ver. •

    require method • Some POSIX based functions Friday, November 2, 12
  25. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Friday, November 2, 12
  26. mobiruby-ios • iOS specific utilities • Bootstrap • Xcode integration

    • Wrapped classes Friday, November 2, 12
  27. 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 Friday, November 2, 12
  28. Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Friday, November 2, 12
  29. Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Q1 2013 Friday, November 2, 12
  30. Current status • Already MobiRuby based app is in AppStore

    • Finally released alpha 1 • Can call almost iOS native functions • Writing test codes • Testing limited Thread feature. • It's only for iOS and mruby hackers Friday, November 2, 12
  31. FAQ • What’s different from RubyMotion? • Can I use

    RubyGems? • Can I use exists Cocoa libraries? • Can I define new method to exist Cocoa class? • What version iOS does it support? Friday, November 2, 12
  32. What’s different from RubyMotion? • RubyMotion is ... • LLVM

    based and compile to native code • extended Ruby syntax • Not Open source • Stable and faster • RubyMotion is ... • LLVM based and compile to native code • extended Ruby syntax • Not Open source • Stable and faster Friday, November 2, 12
  33. What’s different from RubyMotion? Maybe we have same goal. But

    approach is different. • RubyMotion is ... • LLVM based and compile to native code • extended Ruby syntax • Not Open source • Stable and faster Friday, November 2, 12
  34. What’s different from RubyMotion? Maybe we have same goal. But

    approach is different. Friday, November 2, 12
  35. Can I use RubyGems? • No, mruby doesn’t have compatibility

    with CRuby ext. APIs. • You need to write new extension for mruby • bovi and matz has discussed about mrbgems Friday, November 2, 12
  36. Can I use existing Cocoa libraries? • Yes, you can

    use almost all existing libraries. • I think CocoaPods will be a good partner Friday, November 2, 12
  37. 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 Friday, November 2, 12
  38. What version iOS does it support? • MobiRuby supports iOS4

    and higher version • I tested on iOS5. Probably run on iOS4 and 6 Friday, November 2, 12
  39. Wanted contributions • Here’s your big chance! An unexplored field!

    • Need understanding C/Objective-C and iOS development • Try MobiRuby first and build your sample app. Friday, November 2, 12
  40. Questions? • If you have a question, please tweet to

    @mobiruby or post to facebook page. • http://twitter.com/mobiruby • http://facebook.com/mobiruby Friday, November 2, 12
  41. Thank you • Logo design: Maylis Agniel • English review:

    @tenderlove • http://mobiruby.org • http://fb.me/mobiruby • http://twitter.com/mobiruby • http://github.com/mobiruby Friday, November 2, 12