C++ – Ruby vs Lua as scripting language for C++

cluaruby

I am currently building a game server (not an engine), and I want it to be extendable, like a plugin system.
The solution I found is to use a scripting language. So far, so good.

I'm not sure if I should use Ruby or Lua. Lua is easier to embed, but Ruby has a larger library, and better syntax (in my opinion). The problem is, there is no easy way I found to use Ruby as scripting language with C++, whereas it's very easy with Lua.

Toughs about this? Suggestions for using Ruby as scripting language (I tried SWIG, but it isn't nearly as neat as using Lua)?

Thanks.

Best Answer

I've looked at embedding Ruby into C/C++ before, and it seemed extremely difficult. There are a lot of challenges you'll face:

  • Calling into Ruby from C/C++ requires 2 layers of functions to be written (one layer to call, and one to catch exceptions)
  • Calling back into C/C++ from Ruby requires the normal SWIG-type work
  • Moving data back and forth requires keeping careful track of allocations, since Ruby will want to garbage collect anything it can

I'm sure that this can be done, but it seemed extremely difficult to me, only doable if you can jump into Ruby in a minimum of entry points.