mruby & MobiRuby

mruby & MobiRuby

0ec58a040e1e4e959c8566484b4bba19?s=128

Yuichiro MASUI

February 13, 2013
Tweet

Transcript

  1. 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 Thursday, February 14, 13
  2. 3.

    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
  3. 5.

    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
  4. 6.

    Configurable • Drop off unnecessary features • Parser / Compiler

    • Struct, Time, Math, STDIO, Regexp, sprintf • Table algorithm - hash or list • NaN Boxing Thursday, February 14, 13
  5. 7.

    mruby target • Embedded • Digital Appliance • Game console

    • Vendor machine • Bundle with applications Thursday, February 14, 13
  6. 8.

    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
  7. 9.

    development • Spring 2010 - Subsidy • Matz, some companies

    and colleges • April 22, 2012 - Publish to GitHub • mruby got some contributors Thursday, February 14, 13
  8. 10.

    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
  9. 11.

    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
  10. 14.

    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
  11. 16.

    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
  12. 17.

    Vision • Provide Ruby power to Mobile devices • Meta

    programming is most important Ruby power Thursday, February 14, 13
  13. 18.

    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
  14. 19.

    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
  15. 20.

    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
  16. 21.

    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
  17. 22.

    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
  18. 23.

    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
  19. 24.

    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
  20. 25.

    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
  21. 26.

    MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Thursday, February 14, 13
  22. 27.

    MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Thursday, February 14, 13
  23. 28.

    MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Thursday, February 14, 13
  24. 29.

    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
  25. 31.

    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
  26. 32.

    mruby-cfunc \ class TestStruct < CFunc::Struct define CFunc::SInt8, :x, CFunc::SInt16,

    :y end test = TestStruct.new test[:x] = 10 Thursday, February 14, 13
  27. 33.

    MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Thursday, February 14, 13
  28. 34.

    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
  29. 35.

    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
  30. 36.

    Memory management • Objective-C - Reference count • mruby -

    Mark & Sweep • Swizzled Objective-C “release” method • awful performance bottleneck Thursday, February 14, 13
  31. 37.

    MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Thursday, February 14, 13
  32. 38.

    mobiruby-common • Will be common utilities with Android ver. •

    require method • Some POSIX based functions Thursday, February 14, 13
  33. 39.

    MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Thursday, February 14, 13
  34. 40.
  35. 41.

    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
  36. 42.

    Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Thursday, February 14, 13
  37. 43.

    Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Q1 2013 Thursday, February 14, 13
  38. 44.

    Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Q1 2013 Thursday, February 14, 13
  39. 45.

    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
  40. 46.

    Pros. • Ruby power • Based on Matz implemented Ruby

    • mrbgems • MIT license • Compact (~4000 lines) Thursday, February 14, 13
  41. 47.

    Cons. • Unstable • Less classes / functions • Don't

    have debugging feature • Need to understand iOS and Cocoa Thursday, February 14, 13
  42. 48.

    Action! • Provide Ruby Power to the world • Create

    worldwide portfolio • Talk it at one or two foreign conferences Thursday, February 14, 13
  43. 49.

    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
  44. 50.

    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