Skip to content

mrbrdo/mruby_cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What

This enables translating mruby code into C code (not necessarily human readable). The main benefit is increased performance. We cannot achieve performance of real programmer-written C code, but we can improve on performance of interpreted mruby.

Stable enough for testing, but not tested enough for production use.

Install

github.com/mrbrdo/mruby_cc/wiki/Install

Use

echo "puts 'hello world'" > test.rb
./compile test.rb

./runner test.so

Advantages and disadvantages

Advantages

  • improved performance, obviously

  • code is shipped in binary form

    • virtually impossible to get back the original ruby code, because the binary code is compiled from mruby bytecode

    • 3rd party binary obfuscators can be used to make it virtually impossible to recover even the bytecode from which it was compiled

  • output is a C file, which can be manually optimized if necessary (this is an extreme case however)

Disadvantages

  • code is shipped in binary form

    • need to provide precompiled version for each platform, or compile on the fly (currently, this requires gcc or some compiler present on target machine)

    • it is not possible to ensure that the compiled file includes only ruby code, malicious users could include anything - solution is for vendor to oversee user-provided scripts, or to not allow user scripts, also to check CRC of binary to confirm authenticity

  • larger size of binary compared to ruby source file

    • about 300-500KB for typical script

    • compression should be very efficient, especially when compressing multiple files

Dynamic loading of other files

Now it is possible to dynamically load other pre-compiled ruby files.

# some_ruby_file.rb
load_compiled_mrb "dyn.so"

I recommend you use the full file path.

Examples

github.com/mrbrdo/mruby_cc/wiki/Examples

FAQ

github.com/mrbrdo/mruby_cc/wiki/FAQ

Performance

github.com/mrbrdo/mruby_cc/wiki/Performance

About

mruby to C parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published