Your SlideShare is downloading. ×
Mruby & Me
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mruby & Me

569
views

Published on

An introduction to mruby …

An introduction to mruby
http://skillsmatter.com/podcast/home/mruby

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
569
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Mruby & Me Seb JacobsMonday, 11 February 13
  • 2. Matz’s Dream Ruby for everyone, everywhere! flickr/moofbongMonday, 11 February 13
  • 3. So many rubies? JRuby, Rubinius, Topaz, ... why do we need another one?Monday, 11 February 13
  • 4. What is mruby? lightweight ISO-compliant ruby small memory footprint ruby for embedded systemsMonday, 11 February 13
  • 5. mruby is the same but different • compile mruby to bytecode • modular library system • no regexps by default • no standard library • no require!Monday, 11 February 13
  • 6. Hello bytecode $ mruby -e puts "hello lrug"; --verbose 000 OP_LOADSELF!R1 001 OP_STRING! R2! "hello lrug" 002 OP_SEND! R1! :puts! 1 003 OP_STOPMonday, 11 February 13
  • 7. C calling Ruby #include <mruby.h> #include <mruby/compile.h> int main(void) { mrb_state *mrb = mrb_open(); char code[] = "p hello world!"; printf("Executing Ruby code from C!n"); mrb_load_string(mrb, code); return 0; } https://github.com/mruby/mruby/wiki/Hello-WorldMonday, 11 February 13
  • 8. Use it with your favourite language! Ruby in Lua Ruby in PHP Ruby in Node.js!Monday, 11 February 13
  • 9. php-mruby $mrb = new Mruby(); $mrb->assign($myname,sebjacobs); $mrb->run(puts $myname); https://github.com/chobie/php-mrubyMonday, 11 February 13
  • 10. Embedded Ruby! Ruby in your fridge Ruby on your TV Ruby on Wheels!Monday, 11 February 13
  • 11. Build mobile apps with Mobiruby or JamrubyMonday, 11 February 13
  • 12. mod_mruby r = Apache::Request.new() Apache.rputs("redirecting request!") r.filename = "/var/www/html/redirect.html" Apache::return(Apache::OK) https://github.com/matsumoto-r/mod_mrubyMonday, 11 February 13
  • 13. WebRuby https://qiezi.me/projects/webruby-tutorial/Monday, 11 February 13
  • 14. MTest class Test4MTest < MTest::Unit::TestCase def test_assert_empty assert_empty([], array empty) end def test_assert_equal assert_equal(, nil.to_s) end def test_assert_includes assert_includes([1,2,3], 1) end def test_assert_instance_of assert_instance_of Class, Array end end MTest::Unit.new.run https://github.com/iij/mruby-mtestMonday, 11 February 13
  • 15. Get involved!Monday, 11 February 13
  • 16. Module#constants assert(Module#constants, 15.2.2.4.24) do ! module Test4constants ! Const4Test4constant = 24 ! ! end ! module Test4constants2 ! include Test4constants ! ! Const4Test4constant2 = 42 ! ! end ! Test4constants.constants == [:Const4Test4constant] ! Test4constants2.constants == [:Const4Test4constant2] endMonday, 11 February 13
  • 17. Module#constants mrb_value mrb_mod_constants(mrb_state *mrb, mrb_value mod) { ! mrb_value ary; ! ary = mrb_ary_new(mrb); ! if (obj_iv_p(mod) && mrb_obj_ptr(mod)->iv) ! { iv_foreach(mrb, mrb_obj_ptr(mod)->iv, const_i, &ary); ! } ! return ary; }Monday, 11 February 13
  • 18. The future? mruby-rubyMonday, 11 February 13
  • 19. Check out • github.com/mruby/mruby • mruby.sh • github.com/iij/mrubyMonday, 11 February 13
  • 20. I’m @sebjacobs any questions?Monday, 11 February 13

×