Forum: Ruby C embed assistance

Posted by Schala Zeal (schala)
on 2010-02-07 22:55
I was wondering if there was a site with reliable documentation covering
the C embed API? The one on ruby-lang.org is near useless as it was
simply generated without commentary. I could have sworn there was
another site with documentation that explained the stuff and not just
display the declarations. I forgot which site that was and I forgot what
terms I put in Google to find it.
Posted by Christoph Kappel (unexist)
on 2010-02-08 00:08
Schala Zeal wrote:
> I was wondering if there was a site with reliable documentation covering
> the C embed API? The one on ruby-lang.org is near useless as it was
> simply generated without commentary. I could have sworn there was
> another site with documentation that explained the stuff and not just
> display the declarations. I forgot which site that was and I forgot what
> terms I put in Google to find it.

The word 'reliable' is a bit problematic in this case, no docs I found 
so far are something I would like to call that. I had a hard time to 
figuring the stuff out to embed ruby into my window manager 
(http://subtle.subforge.org).

During the time I learned a lot from following urls:

http://www.eqqon.com/index.php/Ruby/Ruby_V1.9_C_Extension
http://metaeditor.sourceforge.net/embed/
http://banisterfiend.wordpress.com/

I started to write down common pitfalls with embedding ruby today 
(http://subforge.org/blogs) and will also help if you have any questions 
I can answer.
Posted by 贾枭 (Guest)
on 2010-02-08 00:53
(Received via mailing list)
I think the book Programming Ruby 1.9 from the pragmatic programmers
will help a lot.

And from my own experience, it is important to understand that writing
ruby extensions and embedding ruby interpreter are the same in
reality.

2010/2/8 Christoph Kappel <unexist@dorfelite.net>:
Posted by Schala Zeal (schala)
on 2010-02-08 02:03
贾枭 wrote:
> I think the book Programming Ruby 1.9 from the pragmatic programmers
> will help a lot.
> 
> And from my own experience, it is important to understand that writing
> ruby extensions and embedding ruby interpreter are the same in
> reality.
> 
> 2010/2/8 Christoph Kappel <unexist@dorfelite.net>:

I guessed that much. I mean if a language can be extended by C, C should 
be able to use it embedded.
Posted by Brian Candler (candlerb)
on 2010-02-08 11:02
Schala Zeal wrote:
> I was wondering if there was a site with reliable documentation covering
> the C embed API? The one on ruby-lang.org is near useless as it was
> simply generated without commentary. I could have sworn there was
> another site with documentation that explained the stuff and not just
> display the declarations. I forgot which site that was and I forgot what
> terms I put in Google to find it.

This one?

http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

That's from a very old version of the book (covering ruby 1.6.8) but the 
fundamentals are the same. Or you can buy a later version as PDF or dead 
tree.
Posted by Christoph Kappel (unexist)
on 2010-02-08 11:37
Schala Zeal wrote:
> I guessed that much. I mean if a language can be extended by C, C should 
> be able to use it embedded.
Inconclusively, I started embedding with 1.8.6 and it was fun to tinker 
a buildsystem that used headers in the right order, ruby had e.g. an own 
regex.h. Also initiating the loadpath with gems isn't strictly forward, 
because when using ruby_options() things will get worse.

The thing with 1.9 that is really annoying while embedding is the 
polling thread that handles ruby threads and signals.
Posted by Schala Zeal (schala)
on 2010-02-08 23:09
How so?
Posted by Tony Arcieri (Guest)
on 2010-02-08 23:40
(Received via mailing list)
Unless there's a magic API I'm not aware of, Ruby doesn't have anything 
like
this.  MRI uses globals which can make embedding difficult and will
certainly prevent you from running multiple copies of the same VM within 
a
single process image.

I know people using an embedded Ruby interpreter, and the general take 
is:
not fun.

If you really want to use Ruby within your application, I'd suggest 
starting
a copy of the Ruby interpreter in another process and talking over 
pipes.
Posted by Schala Zeal (schala)
on 2010-02-09 03:55
You know... I was considering right now about using C# instead of C/C++. 
My main target audience use Windows. For Linux/Mac, perhaps Mono, but 
I've only used version 1.0 of that for development several years ago and 
it was rather slow, compiling and running.

Does anyone have an opinion on this?
Posted by Seebs (Guest)
on 2010-02-09 04:18
(Received via mailing list)
On 2010-02-09, Schala Zeal <schalaalexiazeal@gmail.com> wrote:
> You know... I was considering right now about using C# instead of C/C++. 
> My main target audience use Windows. For Linux/Mac, perhaps Mono, but 
> I've only used version 1.0 of that for development several years ago and 
> it was rather slow, compiling and running.
>
> Does anyone have an opinion on this?

I would not consider C# to be portable past Windows, which for me would
be a dealbreaker.  (Also, if I had my choice of companies on whose code
base and API to bet my future, it would not be Microsoft.  They have too
often said "here is the One True API, code to this and we'll support it
forever" and then killed it a year or two later.)

-s
Posted by Schala Zeal (schala)
on 2010-02-09 04:20
Seebs wrote:
> On 2010-02-09, Schala Zeal <schalaalexiazeal@gmail.com> wrote:
>> You know... I was considering right now about using C# instead of C/C++. 
>> My main target audience use Windows. For Linux/Mac, perhaps Mono, but 
>> I've only used version 1.0 of that for development several years ago and 
>> it was rather slow, compiling and running.
>>
>> Does anyone have an opinion on this?
> 
> I would not consider C# to be portable past Windows, which for me would
> be a dealbreaker.  (Also, if I had my choice of companies on whose code
> base and API to bet my future, it would not be Microsoft.  They have too
> often said "here is the One True API, code to this and we'll support it
> forever" and then killed it a year or two later.)
> 
> -s

MFC, Win32, and DirectX have been around for a while, no?
Posted by Tony Arcieri (Guest)
on 2010-02-09 04:23
(Received via mailing list)
On Mon, Feb 8, 2010 at 7:59 PM, Schala Zeal 
<schalaalexiazeal@gmail.com>wrote:

> You know... I was considering right now about using C# instead of C/C++.
> My main target audience use Windows. For Linux/Mac, perhaps Mono, but
> I've only used version 1.0 of that for development several years ago and
> it was rather slow, compiling and running.
>
> Does anyone have an opinion on this?
>

I hear IronRuby's fairly good (i.e. Ruby for .NET), and it would make
integration a hell of a lot easier than trying to integrate MRI into 
your
C/C++ code.
Posted by Schala Zeal (schala)
on 2010-02-09 04:26
Tony Arcieri wrote:
> On Mon, Feb 8, 2010 at 7:59 PM, Schala Zeal 
> <schalaalexiazeal@gmail.com>wrote:
> 
>> You know... I was considering right now about using C# instead of C/C++.
>> My main target audience use Windows. For Linux/Mac, perhaps Mono, but
>> I've only used version 1.0 of that for development several years ago and
>> it was rather slow, compiling and running.
>>
>> Does anyone have an opinion on this?
>>
> 
> I hear IronRuby's fairly good (i.e. Ruby for .NET), and it would make
> integration a hell of a lot easier than trying to integrate MRI into 
> your
> C/C++ code.

Nice! Uhm... I used Allegro (http://alleg.sf.net) for my gaming API, and 
well... what would be a good choice for .NET? There's likely no DirectX 
for Mono, and Allegro's .NET binding is outdated.
Posted by Seebs (Guest)
on 2010-02-09 06:35
(Received via mailing list)
On 2010-02-09, Schala Zeal <schalaalexiazeal@gmail.com> wrote:
> MFC, Win32, and DirectX have been around for a while, no?

Win32 is old news, it's been .NET for a while.  Before that it was OS/2 
that
was the next target that all MS-platform developers should be looking 
at.
And I think there's been more shifts than that, but some are not 
especially
visible from the outside.

-s
Posted by Marnen Laibow-Koser (marnen)
on 2010-02-10 15:25
Schala Zeal wrote:
> You know... I was considering right now about using C# instead of C/C++. 
> My main target audience use Windows. For Linux/Mac, perhaps Mono, but 
> I've only used version 1.0 of that for development several years ago and 
> it was rather slow, compiling and running.
> 
> Does anyone have an opinion on this?

Use something portable.  It will make it easier to provide other 
versions later.  That probably means not C#, unless Mono will work for 
what you're doing.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.