C / C++ extensions: need all the tips/tricks you can give me

Hi!

I’m looking for all available sources of information on developing ruby
extensions. I’m not a C language expert, but I’ve worked some years ago
as a junior C/C++ developer. For that reason, I think I could get in
business if I find the good resources inside the mess of google results
for “writing ruby C extensions” query…

I would like to hear your suggestions, experiences, gotchas, etc… on
the subject as links to web pages or directly here for both:

  • Essentials C (and C++) language knowledge that I will need
  • Specific ruby extensions tips
  • I need mostly info on 1.8.x mri, but info related to jruby and others
    will be appreciated too.
  • Writing extensions in other languages. I would like info in writing
    extension in D language, for example.

DISCLAIMER: I know how to use google :-). I already did my homework…
Still, I would like to hear suggestions from real experts (that is, YOU
:slight_smile: better than from a stupid computer (that is, google), that always
spits a big amount of junk inside the useful links.

P.S.: My intent is 1) to learn this subject 2) To compile a definitive
document/webpage/wiki/something --with proper credits attached :)-- to
summarize the good info sources I retrieve. You may agree with me that
info on writing C extensions is scarce and scattered all over the web.

P.S.2: I Know that the main source of information is on the ruby source
itself and the txt files bundled. I also know of the Pickaxe chapter on
this. The problem is that, being no C expert, is a little difficult to
me to learn from those sources. That’s why I would also appreciate your
recommendations on good / concise sources of C related knowledge.

On Monday 10 March 2008 15:22:51 Emmanuel O. wrote:

this. The problem is that, being no C expert, is a little difficult to
me to learn from those sources. That’s why I would also appreciate your
recommendations on good / concise sources of C related knowledge.

Well, you’ve written pretty much everything anyone could tell you on a
generic
question about ruby extension programming. The ruby C API is pretty
straightforward, it is documented in file README.EXT which comes with
ruby
source, and as you said yourself you can find many sources on the
subject all
over the net. So far i wrote two extensions and i can’t think of any
serious
problem or a tip that wouldn’t be mentioned in the docs.

Really the best way to learn this is to just start coding, and see if
you’ll
hit any problems, then you can ask specifically, and i’m sure everyone
here
will try to help you.

Also, if you’ll start exercising your C skills, remember that C and C++
are
two radically different languages, that share common syntax by mere
accident :slight_smile:

Jan

Well, you’ve written pretty much everything anyone could tell you on a
generic question

Wow!!! I tried my best, but you skillfully gave me the answer I was
trying to avoid! (no offense, just a joke! :slight_smile: )

You are very very right. Still, by browsing these very forums and all
over the web I found tips like “beware of multi-threading” or “don’t do
this when writing a binding for a c++ lib”. I’m just trying to get up to
date tips and links that I may have loose on my research.

Really the best way to learn this is to just start coding, and see if
you’ll hit any problems, then you can ask specifically, and i’m sure everyone
here will try to help you.

Thanks! I use to get all info I can get before starting a project.
That’s why I asked first, but again you are right. Still would like to
receive tips / links in advance