Search code examples
pythonrubymruby

The difference of mruby and embedding Python in C program


In mruby, we can embed the ruby code in a C program.

We can also do this in Python.

Is there any difference in the principle of these two?


Solution

  • There is similarity, and a difference, between the two.

    The goal of mruby is two-fold:

    1. Make it possible to compile Ruby to C (or, to look at it from another direction, to embed Ruby code into a C program).
    2. Make it possible to run this compiled Ruby code on a mobile platform.

    The first characteristic, which is what you're asking about, shares commonality with Python, Lua, and other scripting languages.

    The second characteristic is similar to Lua (which can run on iOS and Android, via Corona SDK). Among others, there is MobiRuby, which uses mruby to create an iOS project which you can use to write Ruby code and make iOS apps. (Their plan is to adopt Android as well.)

    This is not something Python is doing yet. AFAIK, Python (and Ruby) can use SL4A to run on Android. This is not the same as compiling to C and running as an embedded part of a bigger program.