From: Joel VanderWerf Date: 2006-07-12T10:30:54+09:00 Subject: Re: Good way to write a C extension to Ruby? Marcin Miel��y��ski wrote: > vasudevram wrote: >> Hi, >> >> Whats a good way to write a C extension to Ruby? >> >> I'm aware that there's a chapter about in the Pickaxe book (I think), >> and will be checking that out, and also SWIG, if it supports Ruby. But >> looking for replies from anyone who has already tried any of these >> ways, and their feedback. > > > Swig is brilliant and has very good support for Ruby, it will help you > automate many tasks - it has it's own DSL (argh...). Actually I used it > to wrap my C++ code. It is also worth mentioning that Ruby has the most > consistent and easy to understand/use c api I've seen (Lua's api is also > very clear) - just look into Ruby sources: array.c and hash.c - you'll > realize what I'm talking about ;D I'll second all of that. Understanding README.EXT and some small examples is the best first step to using SWIG or writing an extension from scratch. Maybe the OP could give us some more details about the nature of the extension... wrapping a library? defining methods that work with ruby classes in a more efficient way that calling ruby methods? a new data structure implemented from scratch? -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407