mrubyとものづくり

0ec58a040e1e4e959c8566484b4bba19?s=47 Yuichiro MASUI
May 18, 2013
160

 mrubyとものづくり

2013/05/18 名古屋にて

0ec58a040e1e4e959c8566484b4bba19?s=128

Yuichiro MASUI

May 18, 2013
Tweet

Transcript

  1. mrubyͱ΋ͷͮ͘Γ Yuichiro MASUI a.k.a. @masuidrive Saturday, May 18, 13

  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 Saturday, May 18, 13
  3. Saturday, May 18, 13

  4. Saturday, May 18, 13

  5. 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 Saturday, May 18, 13
  6. 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 Saturday, May 18, 13
  7. 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 Saturday, May 18, 13
  8. 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 ϛΠϧ Saturday, May 18, 13
  9. Webܥͷํ Saturday, May 18, 13

  10. εϚϗܥͷํ Saturday, May 18, 13

  11. ૊ΈࠐΈܥͷํ Saturday, May 18, 13

  12. mruby Saturday, May 18, 13

  13. 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 Saturday, May 18, 13
  14. Configurable • Drop off unnecessary features • Parser / Compiler

    • Struct, Time, Math, STDIO, Regexp, sprintf • Table algorithm - hash or list • NaN Boxing Saturday, May 18, 13
  15. mruby target • Embedded • Digital Appliance • Game console

    • Vendor machine • Bundle with applications Saturday, May 18, 13
  16. mruby target Saturday, May 18, 13

  17. mruby target Saturday, May 18, 13

  18. mruby target Saturday, May 18, 13

  19. mruby target • CPU - 32bit, FPU • Memory -

    256KB - 1MB • OS Saturday, May 18, 13
  20. mruby internals • VM structure - Multi VM instance •

    No C global variable • Generational incremental GC (Mark&Sweep) • Not thread safe • Build system build on CRuby Saturday, May 18, 13
  21. development • Spring 2010 - Subsidy • Matz, some companies

    and colleges • April 22, 2012 - Publish to GitHub • mruby got some contributors Saturday, May 18, 13
  22. mrbgems • Daniel (@bovi) created extension package feature at end

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

    of Nov 2012. • Easy to install from GitHub • Supported cross build • Already provided 40+ gems Saturday, May 18, 13
  24. topics • mrbgems - gembox • Refactoring for portability Saturday,

    May 18, 13
  25. wrap up • mruby͕໨ࢦ͢ͷ͸਺೥ޙͷੈք • CRuby͸Ruby͕ओɺmruby͸ै • ૊ΈࠐΉઌ͸σόΠε͚ͩ͡Όͳ͍ • ࢓ࠐΉͳΒࠓ

    Saturday, May 18, 13
  26. Saturday, May 18, 13

  27. Saturday, May 18, 13

  28. 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? Saturday, May 18, 13
  29. Saturday, May 18, 13

  30. 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 Saturday, May 18, 13
  31. Vision • Provide Ruby power to Mobile devices • Meta

    programming is most important Ruby power Saturday, May 18, 13
  32. 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 Saturday, May 18, 13
  33. 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 Saturday, May 18, 13
  34. 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 Saturday, May 18, 13
  35. 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 Saturday, May 18, 13
  36. 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 Saturday, May 18, 13
  37. 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 Saturday, May 18, 13
  38. 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 Saturday, May 18, 13
  39. 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 Saturday, May 18, 13
  40. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Saturday, May 18, 13
  41. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Saturday, May 18, 13
  42. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Saturday, May 18, 13
  43. mruby-cfunc • C function bridge for mruby • Call C

    based function directly • Based on libFFI • Same as Ruby/DL library on CRuby Saturday, May 18, 13
  44. mruby-cfunc str  =  "STRING" CFunc::call(CFunc::Void,  "puts",  str) STRING Saturday, May

    18, 13
  45. mruby-cfunc str  =  "STRING" ptr  =  CFunc::Pointer.malloc(7) result_ptr  =  CFunc::call(CFunc::Pointer,

      "strcpy",  ptr,  str) ptr.to_s -­‐>  “STRING” Saturday, May 18, 13
  46. mruby-cfunc \ class  TestStruct  <  CFunc::Struct        define

     CFunc::SInt8,    :x,                      CFunc::SInt16,  :y end test  =  TestStruct.new test[:x]  =  10 Saturday, May 18, 13
  47. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Saturday, May 18, 13
  48. 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 Saturday, May 18, 13
  49. 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 Saturday, May 18, 13
  50. Memory management • Objective-C - Reference count • mruby -

    Mark & Sweep • Swizzled Objective-C “release” method • awful performance bottleneck Saturday, May 18, 13
  51. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Saturday, May 18, 13
  52. mobiruby-common • Will be common utilities with Android ver. •

    require method • Some POSIX based functions Saturday, May 18, 13
  53. MobiRuby stack iOS mruby mruby- cfunc Your code mruby- cocoa

    mobiruby- common mobiruby- ios Saturday, May 18, 13
  54. mobiruby-ios • iOS specific utilities • Bootstrap • Xcode integration

    • Wrapped classes Saturday, May 18, 13
  55. 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 Saturday, May 18, 13
  56. Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Saturday, May 18, 13
  57. Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Q1 2013 Saturday, May 18, 13
  58. Road map • Finished building Cocoa bridge • Fix bugs,

    Improvement • Packaging • Documentation • Build wrapped APIs Version 1 Summer 2013 Saturday, May 18, 13
  59. 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 Saturday, May 18, 13
  60. Pros. • Ruby power • Based on Matz implemented Ruby

    • mrbgems • MIT license • Compact (~4000 lines) Saturday, May 18, 13
  61. Cons. • Unstable • Less classes / functions • Don't

    have debugging feature • Need to understand iOS and Cocoa Saturday, May 18, 13
  62. Topics • ΋ͷͮ͘ΓΛऔΓרٕ͘ज़ • Ϋϥ΢υϑΝ΢ϯσΟϯά Saturday, May 18, 13

  63. PCܥٕज़ͷԠ༻ • ૊ΈࠐΈ༻؀ڥ͸ҰੲલͷPCฒ • ։ൃ؀ڥ • ARM • खܰͳ࣮ߦ؀ڥ •

    Arduino, Raspberry Pi Saturday, May 18, 13
  64. ݸਓతͳτϐοΫ • Bluetooth 4.0 • BLE • iOS6Ͱαϙʔτ Saturday, May

    18, 13
  65. ਎ମੑ • ΋ͷͮ͘Γͷָ͠͞͸਎ମੑ • ͭ͘Δ਎ମੑ • σόΠεͷ਎ମੑ Saturday, May 18,

    13
  66. Saturday, May 18, 13

  67. झຯ͔Β • झຯ͔Β࢓ࣄͷੈք͕มΘΔ • PCͰ͸90೥୅ʹ஍֪มಈ͕ىͬͨ͜ Saturday, May 18, 13

  68. ڥքʹ͍Δ • ෳ਺ͷٕज़΍ཁٻͷڥքʹ৽͍͠࢓ࣄ͕ੜ· ΕΔ • ໘ന͍ద౓ͳαΠζͷ໰୊Λݟ͚ͭΔ Saturday, May 18, 13

  69. Ϋϥ΢υϑΝ΢ϯσΟϯά • Kick starterɹ • ੜ࢈ͷϋʔυϧ͕େ͖͘Լ͕Δ • ϦϦʔεޙʹࠅධΛड͚Δ͜ͱ΋͋Δ Saturday, May

    18, 13
  70. Saturday, May 18, 13

  71. ·ͬͨؔ͘܎ͳ͍࿩ http://wri.pe Saturday, May 18, 13

  72. 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 Saturday, May 18, 13