Hi Patrick,
> I am trying to decided whether to embed Ruby or Python.
>
> It looks like Ruby is not ideal for embedding but it also sounds like it
> is doable as long as it's called from main, is that true?
>
> The Ruby C API looks lighter but much easier to work with.
I've done both.
This isn't going to be a popular opinion given the list (please be gentle everyone!), but in my experience the Python embedding API was far easier to work with, clearer, cleaner, and better documented compared to Ruby. I don't like this situation, but it has been my experience thus far.
Note that I'm assuming MRI, which I'm using. I can't speak for the other Ruby variants.
However: Another consideration is choosing an embedded language is what you ultimately want people to use when writing embedded scripts. Having used both, and both APIs, I settled on Ruby for my project, because I'd rather be able to write the embedded code in Ruby than Python. The Ruby embedding API may be weaker (IMHO), but the Ruby language itself is far superior (also IMHO). In my case, the additional effort was worth it.
Incidentally, I've added my own C++ API over the top in my own code, and it's now a breeze to work with. The biggest thing for me was wrapping over the details of registration/unregistration, as well as calls and exception management.
I can also confirm that what you want to do is definitely doable. I'm doing it. 
> Is VALUE the only type?
Essentially, yes. Even as handles for opaque data types. Even used as as a placeholder for anonymous pointers on occasion, which can really mess with your head sometimes.
> Is it true that I do not have to manually increment and decrement values
> as well?
You have to watch out for cases where the garbage collector might come calling for any VALUES. Essentially, I believe you're safe as long as the value is sitting somewhere in the stack, but if you want to be certain, you need to register the VALUE, and unregister when done, or otherwise make your data participate in the mark and sweep process. If you forget this, you will eventually start getting unexplained segmentation faults.
Note that when you've got everything working fine, it's extremely stable.
> I was also wondering about extending Ruby. If I create a C module FOO
> and another module POO, can FOO call functions from POO or is there a
> way to make them visible? I might like to call TK from another C module
I believe so, but I've not done it. I have made calls in C++ to a Ruby script which has called a registered function back in my C++ code- it's an essential part of my code, so I can confirm that this variant is 100% possible. 
> Any feedback or corrections on this topic would be appreciated.
I hope this helps.
I'd also check out those other posts re mruby. I don't know anything about it, but I'll probably be checking it out myself. 
Garth
···
On 21/02/13 01:27, Patrick wrote: