From: Mat Brown Date: 2010-02-14T01:11:42+09:00 Subject: Re: Getting started with the C API On Sat, Feb 13, 2010 at 10:25, Marvin Humphrey wrote: > Greets, > > I've been teaching myself Ruby using David Black's book, "The > Well-Grounded Rubyist".  5 chapters in or so, things are going well. > However, things would be going even better if I was able to get > started on the project that's motivating my course of study: there's a > C library I'd like to write Ruby bindings for. > > The Black book, while appropriate in pace and tone for an experienced > programmer, doesn't cover any sort of Ruby C API.  The pickaxe book > does, but before I go and buy a copy of that, I'd like to know if > those pickaxe chapters are really the canonical reference.  That seems > weird. > > What I'm looking for is the analogue to these pages: > >  http://perldoc.perl.org/perlxstut.html >  http://docs.python.org/3.1/c-api/index.html >  http://java.sun.com/docs/books/jni/html/jniTOC.html > > From what I can tell, the closest thing Ruby has to that is a raw > Doxygen dump... > >  http://www.ruby-doc.org/doxygen/current/ > > ... but that's not much better than just spelunking the source code, > because it doesn't give you any idea where to get started. > > I know the first edition of the pickaxe book is online, but I don't > like to waste time learning from dated materials. > > Where should I be looking? > > Marvin Humphrey > > > If you download the Ruby source, there's a file called README.EXT which gives a pretty good, detailed treatment of the Ruby C API. Better than anything I've seen online. Here it is in the Ruby SVN: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8/README.EXT This article on Ruby Inside gives you a quick primer on using mkmf to build a Makefile so you can start playing around with it: http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html