8. We, Web developers, Are Spoiled
• Deploying/updating our apps is easy
• Only have to care about a few of servers in the production
• We can always SSH into a server and see what's wrong
• Our servers run in the comfort of the cloud
• Testing/debugging also easy
• We have all the computing power we want
• We can use any technology we want
9. Meanwhile on Embedded Devices
• Deploying/updating is a nightmare
• There can be dozens/thousands of embedded systems running your app
• Little power, sometimes constrained battery life
• Testing/debugging on the device takes effort
• You have no control of the environment they are in
• The added trouble of communication with and between devices
• Security...
• You are stuck with C, C++, maybe Java (unless you run on Unix)
11. MRuby
• Another interpreter for Ruby
• The other ones won't run without OS or on RTOS
• Also a compiler and VM
• Very lightweight (<128kb)
• Compatible with Ruby 1.9 syntax
• Runs on anything that can run C
12. MRuby is Lightweight
• Only platform independent functionality
• Everything else is a gem (mrbgem)
• e.g. IO, threads, require
13. mrbgems
• Defined in build_config.rb
• Can be:
• Pure Ruby – Defines the extension class in Ruby
• Pure C – Builds the class in C
• C and Ruby – Defines some methods in C and
some in Ruby
14. MRuby is Embeddable
• Can be run inside other applications
• Great for scripting, configuration
*.rb
/usr/bin/ruby
C/C++ app
*.rb
bytecode
libmruby.a
Source: http://www.slideshare.net/yamanekko/rubyconf2013?qid=dd845db4-dda5-44a5-81c3-0fa63ca520f2&v=qf1&b=&from_search=8
15. 4 Ways to Run MRuby
1. Interpreted
2. Interactive shell
3. Bytecode
4. Generating C code
Source: http://blog.mruby.sh/201207020720.html
16. Interpreted
• Just like any other Ruby app
$ mruby hello_world.rb
Hello World
• Good for testing
• Overhead
18. Bytecode
$ mrbc hello_world.rb
• Will produce platform independent bytecode in
hello_world.mrb
$ mruby -b hello_world.mrb
Hello World
• Will run the bytecode in a VM
• Less overhead – no parsing
• Still need the mruby program to run it
19. Generating C Code
• Integrate Ruby code in a C application
• Generates C files containing the Ruby code
• A standalone app – without any requirements
• The user doesn't see the source code
21. But That's OK
• There is a trend in IoT:
• Dumb devices that only provide resources/
services
• Most of the application logic in the cloud
• MRuby fits this use case well despite performance
issues
• Besides it's very young and will improve
22. One Less Issue
• Deploying/updating is a nightmare
• There can be dozens/thousands of embedded systems running your app
• Little power, sometimes constrained battery life
• Testing/debugging on the device takes effort
• You have no control of the environment they are in
• The added trouble of communication with and between devices
• Security...
• You are stuck with C, C++, maybe Java (unless you run on Unix)
23. So, now we have the
MRuby, we just need the
MRuby on Rails
24. My PhD Project
• A platform/framework for deploying apps to embedded devices
• Define some conventions and architecture
• App Store like software ecosystem
• Secure environment for apps
• Open interfaces and communication
• I'm just starting my PhD
• Any feedback is very appreciated