GithubHelp home page GithubHelp logo

mruby_cc's Introduction

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

mruby_cc's People

Contributors

mrbrdo avatar otobrglez avatar

Watchers

J  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.