Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
A naïve introduction to mruby
Search
Jason L Perry
August 21, 2014
Technology
3
820
A naïve introduction to mruby
Slides from a short talk given to the Tampa Ruby Brigade on August 21, 2014.
Jason L Perry
August 21, 2014
Tweet
Share
More Decks by Jason L Perry
See All by Jason L Perry
Tomorrow's Javascript, Today.
ambethia
0
95
Advanced JS Crash Course
ambethia
1
390
Intro to Javascript
ambethia
1
100
Ruby for the Newbie
ambethia
2
130
Other Decks in Technology
See All in Technology
Node-REDのFunctionノードでMCPサーバーの実装を試してみた / Node-RED × MCP 勉強会 vol.1
you
PRO
0
110
【TiDB GAME DAY 2025】Shadowverse: Worlds Beyond にみる TiDB 活用術
cygames
0
1.1k
Understanding_Thread_Tuning_for_Inference_Servers_of_Deep_Models.pdf
lycorptech_jp
PRO
0
120
VISITS_AIIoTビジネス共創ラボ登壇資料.pdf
iotcomjpadmin
0
160
HiMoR: Monocular Deformable Gaussian Reconstruction with Hierarchical Motion Representation
spatial_ai_network
0
110
PHP開発者のためのSOLID原則再入門 #phpcon / PHP Conference Japan 2025
shogogg
4
730
フィンテック養成勉強会#54
finengine
0
180
PHPでWebブラウザのレンダリングエンジンを実装する
dip_tech
PRO
0
200
あなたの声を届けよう! 女性エンジニア登壇の意義とアウトプット実践ガイド #wttjp / Call for Your Voice
kondoyuko
4
440
強化されたAmazon Location Serviceによる新機能と開発者体験
dayjournal
2
210
なぜ私はいま、ここにいるのか? #もがく中堅デザイナー #プロダクトデザイナー
bengo4com
0
410
急成長を支える基盤作り〜地道な改善からコツコツと〜 #cre_meetup
stefafafan
0
120
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Code Reviewing Like a Champion
maltzj
524
40k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Navigating Team Friction
lara
187
15k
A designer walks into a library…
pauljervisheath
207
24k
Gamification - CAS2011
davidbonilla
81
5.3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Scaling GitHub
holman
459
140k
Transcript
mruby A naïve introduction to
Embedded Devices Native Applications Scripting Applications
Know some Ruby Know some C Know Japanese Getting Started
Ask Google: “mruby [ANYTHING]”
< 128kb
None
`require`
stdlib
mrbgems
mruby-array-ext mruby-bin-mirb mruby-bin-mruby-config mruby-bin-mruby mruby-bin-strip mruby-enum-ext mruby-enum-lazy mruby-enumerator mruby-eval mruby-exit
mruby-fiber mruby-hash-ext mruby-kernel-ext mruby-math mruby-numeric-ext mruby-object-ext mruby-objectspace mruby-print mruby-proc-ext mruby-random mruby-range-ext mruby-sprintf mruby-string-ext mruby-string-utf8 mruby-struct mruby-symbol-ext mruby-time mruby-toplevel-ext
MRuby::Build.new do |conf| toolchain :gcc conf.gem :core => 'mruby-bin-mirb' conf.gem
:core => 'mruby-bin-mruby' conf.gem :core => 'mruby-print' conf.gem :core => 'mruby-proc-ext' conf.gem :core => 'mruby-sprintf' conf.gem :core => 'mruby-time' ! conf.gem :git => 'https://github.com/iij/mruby-io.git' conf.gem :git => 'https://github.com/iij/mruby-mtest.git' conf.gem :git => 'https://github.com/iij/mruby-socket.git' end build_config.rb
Many Ways
Interpreted $ mruby hello_world.rb Hello, World. ! $ mruby -e
“Hello, World!” Hello, World.
Interactive Shell (mirb) $ mirb mirb - Embeddable Interactive Ruby
Shell ! > puts "Hello, World!" Hello, World! => nil
Bytecode (*.mrb) $ mrbc hello_world.rb $ cat -v hello_world.mrb RITE0002&?
^@^@^@gMATZ0000IREP^@^@^@I0000^@^@^@=^@^A^@^D^@ ^@^@^@^@^D^@M-^@^@^F^A^@^@=^@M-^@^@? ^@^@^@J^@^@^@^A^@^@^MHello, World! ^@^@^@^A^@^Dputs^@END^@^@^@^@^H% $ mruby -b hello_world.mrb Hello, World!
Binary C Code $ mrbc -B hello_world_bin hello_world.h $ cat
hello_world.h const char hello_world_bin[] ={ 0x52,0x49,0x54,0x45,0x30,0x30,0x30,0x39,0x30,0x 30,0x30,0x30,0x30,0x30,0x30,0x39,… };
Binary C Code #include <mruby.h>! #include <mruby/irep.h>! ! #include “hello_world.h”!
! int main(void)! {! mrb_state *mrb;! mrb = mrb_open();! mrb_load_irep(mrb, hello_world_bin);! mrb_close(mrb);! return 0;! }
Running Ruby from C // car = Car! // car.run!
struct RClass *Car = mrb_class_get(mrb, "Car");! mrb_value merv = mrb_class_new_instance(mrb, 0, NULL, Car);! mrb_funcall(mrb, car, "run", 0, NULL);!
CODE SPELUNKING github.com/ambethia/merv