Reading the ruby source

Hi.
I'd like to read the ruby source (that is, the source that when compiled,
yields the ruby interpreter). I have them, and I've had a look, but I just
get overwhelmed. I've never read a big c program before, and I was wondering
if anyone had any advice on where to start, or if there has been any
documentation?
Sorry it's a bit OT
thanks

robbie

It depends on what you want to get out of reading the source. Do you want to understand some particular aspect of Ruby? Or do you just want to understand what it does, from the moment you invoke the interpreter?

If you just want an overall understanding of the flow of the interpreter, I'd recommend starting with main. Then, with grep at your side, step through the function and the functions it calls.

- Jamis

···

On Sep 20, 2005, at 11:25 AM, Robbie Carlton wrote:

Hi.
I'd like to read the ruby source (that is, the source that when compiled,
yields the ruby interpreter). I have them, and I've had a look, but I just
get overwhelmed. I've never read a big c program before, and I was wondering
if anyone had any advice on where to start, or if there has been any
documentation?
Sorry it's a bit OT
thanks

robbie

Robbie Carlton wrote:

Hi.
I'd like to read the ruby source (that is, the source that when compiled, yields the ruby interpreter). I have them, and I've had a look, but I just get overwhelmed. I've never read a big c program before, and I was wondering if anyone had any advice on where to start, or if there has been any documentation?

Try README.EXT which comes with Ruby. It'll give ya a quick gloss over everything.

From there, I'd look over ruby.h and intern.h, which will give you a tour of the major structs and functions.

When you start diving into the various source files, note the Init_ functions at the end of each of them. (string.c has an Init_String, marshal.c has Init_marshal, etc.) These functions create the actual Ruby modules, classes and methods from their C counterparts.

_why

While reading any big C program, I recommend using setting up Cscope. Some
projects have this as a target in the Makefile (although I don't remember if
Ruby is one of them). You can quickly search for functions when you run into
them, without the grepping. If you prefer, you can even set up Emacs or Vim
with cscope. For more info:

Rob

···

On 9/20/05, Robbie Carlton <robbie.carlton@gmail.com> wrote:

I've never read a big c program before, and I was wondering
if anyone had any advice on where to start, or if there has been any
documentation?

thanks for the road-map. I've just got stuck in. README.EXT is very handy,
and I hadn't even thought of grep (I'm on a mac, and the unix underbelly is
still not second nature yet).
also, kudos for the funny book why.

···

On 9/20/05, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:

Robbie Carlton wrote:

>Hi.
>I'd like to read the ruby source (that is, the source that when compiled,
>yields the ruby interpreter). I have them, and I've had a look, but I
just
>get overwhelmed. I've never read a big c program before, and I was
wondering
>if anyone had any advice on where to start, or if there has been any
>documentation?
>
Try README.EXT which comes with Ruby. It'll give ya a quick gloss over
everything.

From there, I'd look over ruby.h and intern.h, which will give you a
tour of the major structs and functions.

When you start diving into the various source files, note the Init_
functions at the end of each of them. (string.c has an Init_String,
marshal.c has Init_marshal, etc.) These functions create the actual
Ruby modules, classes and methods from their C counterparts.

_why

Also it might help to read about creating C extensions for ruby. The
pick-axe book has a chapter.

···

On 9/20/05, Robbie Carlton <robbie.carlton@gmail.com> wrote:

thanks for the road-map. I've just got stuck in. README.EXT is very handy,
and I hadn't even thought of grep (I'm on a mac, and the unix underbelly is
still not second nature yet).
also, kudos for the funny book why.

On 9/20/05, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:
>
> Robbie Carlton wrote:
>
> >Hi.
> >I'd like to read the ruby source (that is, the source that when compiled,
> >yields the ruby interpreter). I have them, and I've had a look, but I
> just
> >get overwhelmed. I've never read a big c program before, and I was
> wondering
> >if anyone had any advice on where to start, or if there has been any
> >documentation?
> >
> Try README.EXT which comes with Ruby. It'll give ya a quick gloss over
> everything.
>
> From there, I'd look over ruby.h and intern.h, which will give you a
> tour of the major structs and functions.
>
> When you start diving into the various source files, note the Init_
> functions at the end of each of them. (string.c has an Init_String,
> marshal.c has Init_marshal, etc.) These functions create the actual
> Ruby modules, classes and methods from their C counterparts.
>
> _why
>
>

--
Nicholas Van Weerdenburg