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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Jason L Perry
August 21, 2014
Technology
880
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
More Decks by Jason L Perry
See All by Jason L Perry
Tomorrow's Javascript, Today.
ambethia
0
110
Advanced JS Crash Course
ambethia
1
420
Intro to Javascript
ambethia
1
110
Ruby for the Newbie
ambethia
2
130
Other Decks in Technology
See All in Technology
Kubernetesにおける学習基盤とLLMOpsの概要
ry
1
320
FPC(フレキシブル)基板にZephyr実装してみた。
iotengineer22
0
100
エラーバジェットのアラートのタイミングを考える.pdf
kairim0
0
170
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
2k
アンオフィシャルな、オフィシャルからのお願い
wyamazak_devrel
0
140
現地で盛り上がった WWDC26 Keynote
zozotech
PRO
1
270
RAG を使わないという選択肢
tatsutaka
1
270
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
3k
【Snowflake Summit 2026 Recap!!】Snowflake Summit Deep Dive: Security & Governance
civitaspo
1
260
2026年6月23日 Syncable Tech + Start Python Club にて
hamukazu
0
140
200個のGitHubリポジトリを横断調査したかった
icck
0
140
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
1.3k
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
200
Google's AI Overviews - The New Search
badams
0
1k
Into the Great Unknown - MozCon
thekraken
41
2.6k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Designing for Timeless Needs
cassininazir
1
260
Odyssey Design
rkendrick25
PRO
2
700
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
How to Ace a Technical Interview
jacobian
281
24k
How to build a perfect <img>
jonoalderson
1
5.7k
Ruling the World: When Life Gets Gamed
codingconduct
0
260
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
210
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