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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Jason L Perry
August 21, 2014
Technology
870
3
Share
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
AI Adaptable なテストを整える工夫 / Ways to Make Your Tests AI-Adaptable
bitkey
PRO
2
200
AIプラットフォームを運用し続けるための可観測性
tanimuyk
4
970
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
9
5.4k
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
210
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
970
Generative UI × A2UI で AI エージェントを作った話 AI-DLC も使ってみた!
kmiya84377
1
310
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
460
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
170
大規模災害時でも高い信頼性を維持するアプリケーション基盤の実現/nikkei-tech-talk46
nikkei_engineer_recruiting
0
130
JEP 522 Deep Dive - G1 GC同期コスト削減によるスループット向上を徹底検証&解説
tabatad
1
600
先取りMaven4 ~16年ぶりのメジャーアップデート、その進化とは?~
ogiwarat
0
120
20260528_生成AIを専属DSに_Howの次にすべきことを考える
doradora09
PRO
0
280
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
780
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
440
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
22k
How GitHub (no longer) Works
holman
316
150k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
エンジニアに許された特別な時間の終わり
watany
107
240k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
My Coaching Mixtape
mlcsv
0
140
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
520
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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