[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: converting some autogenerated ruby code to C

Berger, Daniel

7/27/2006 9:47:00 PM



> -----Original Message-----
> From: Eric Mahurin [mailto:eric.mahurin@gmail.com]
> Sent: Thursday, July 27, 2006 3:26 PM
> To: ruby-talk ML
> Subject: converting some autogenerated ruby code to C
>
>
> One of the next things I want to do in my grammar package is
> to give it a performance boost by generating C code instead
> of ruby code. Right now the parsers I generate are a set of a
> few methods with giant expressions in each. I would like to
> try improving the performance by generating and compiling C
> code instead. My preference would be to convert my small
> subset of ruby code to C code (easily have an option to use
> pure ruby or use ruby/C), but I could also autogenerate C
> code instead. Anybody have any opinions/ideas about what
> approach I whould take?

Couldn't you start with Ruby, see how it performs, and add C support
later? Or does it become more difficult later?

Just remember, not everyone has a C compiler on their system...

Regards,

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.

4 Answers

Eric Mahurin

7/28/2006 3:10:00 PM

0

On 7/27/06, Berger, Daniel <Daniel.Berger@qwest.com> wrote:
> > One of the next things I want to do in my grammar package is
> > to give it a performance boost by generating C code instead
> > of ruby code. Right now the parsers I generate are a set of a
> > few methods with giant expressions in each. I would like to
> > try improving the performance by generating and compiling C
> > code instead. My preference would be to convert my small
> > subset of ruby code to C code (easily have an option to use
> > pure ruby or use ruby/C), but I could also autogenerate C
> > code instead. Anybody have any opinions/ideas about what
> > approach I whould take?
>
> Couldn't you start with Ruby, see how it performs, and add C support
> later? Or does it become more difficult later?

I've already have a pure ruby solution. There are a couple reasons I
would like to have an alternate C solution:

* I'm not using regular expressions at the lowest level. The solution
I have has a superset of the functionality of regular expressions
(full parsing, works on more than just strings). I would rather not
move to use regular expressions just for the sake of performance. I
may still do it at some point, but it will add ugliness since I have
to buffer into a string. Instead, I would rather just get the same
advantage that regular expressions have - they are written in C. I'm
not sure if I would be able to quite get to the regex performance or
not. On one hand, I'm doing code generation/compiling and Regexp is
just putting the regex into a more manageable structure. On the other
hand, my solution is duck-typed and not tied to String, so I'll have
messaging overhead for each additional char/token/element read
(input.read1next) and checked (pattern.===).

* I would like to get this parsing on par with parsers from other
languages - YACC, ANTLR, etc. I would like to get some bragging
rights relative to these. Of course, when you add ruby actions
(blocks) in the parsing this could slow things down quite a bit, since
you're back into ruby instead of C.

> Just remember, not everyone has a C compiler on their system...

That's why I'll provide a pure ruby and a ruby/C solution.

Anybody want to point me to some examples/docs of ruby2c, rb2c, etc?

Ara.T.Howard

7/28/2006 3:15:00 PM

0

pat eyler

7/28/2006 4:56:00 PM

0

On 7/28/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
> On Sat, 29 Jul 2006, Eric Mahurin wrote:
>
> > That's why I'll provide a pure ruby and a ruby/C solution.
> >
> > Anybody want to point me to some examples/docs of ruby2c, rb2c, etc?
>
> why not just use ruby-inline? it's probably the easiest way to generate c
> from ruby.

well, Ruby2C generates C from Ruby .. RubyInline lets you put some C
in your Ruby.

>
> -a
> --
> we can never obtain peace in the outer world until we make peace with
> ourselves.
> - h.h. the 14th dali lama
>
>


--
thanks,
-pate
-------------------------
http://on-ruby.bl...

Vixxen

7/16/2009 12:33:00 AM

0

On Jul 15, 8:30 pm, deb <dwal...@tx.rr.com> wrote:
> On Jul 15, 7:16 pm, Vixxen <onyxenlightenm...@gmail.com> wrote:
>
> > On Jul 15, 8:14 pm, deb <dwal...@tx.rr.com> wrote:
>
> > > Are you a Wiccan?- Hide quoted text -
>
> > > - Show quoted text -
>
> > Ask Michelle, h/she has all the answers about me.  He knows me better
> > than I do.  He knows everything!  LOL
>
> > Go bake a pie, Blown Bulb.
>
> I prefer direct conversations, that's why I asked you.  Are you
> Wiccan?  If you don't want to answer, you can so you don't want to
> answer.

Didn't I tell you to get your ass in the kitchen!? I, the
Goddess..commands it. LOLOLOLOLOLOLOL

You really are a Blown Bulb, you must be the true pagan.