David G. Andersen wrote:

> On Sun, Nov 07, 2004 at 07:48:38AM +0900, Christian Szegedy scribed:
> 
>>David G. Andersen wrote:
>>
>>>If we had a superfast matrix class, it would give (a) along
>>>with decreasing the runtime by a factor of ten or so.  Sounds
>>>reasonable.  The same test in matlab would be about 1/4 the lines of
>>>code and 20x faster if implemented the way it should be.
>>
>>Great! Then put all C-solutions from the shootout into
>>an extension and call them from Ruby. This way, Ruby
>>would have the second place in runtime after C and
>>the 1st in LOC count.
> 
> 
>   This doesn't follow.  Ruby _already_ has a matrix convenience
> class - my point is simply that by adding 61 additional lines of
> code (73 lines of C - the 12 lines of ruby it replaces), we turn
> the internal matrix class from something that's twice as slow
> as what you would get if you implemented the whole thing in 
> optimized ruby to something that's 5x faster.  Being able to use
> an already well-implemented matrix class is a very nice bonus;
> who wants to roll their own just to speed things up a bit?
> 

What's the criteria for having Ruby include something written in C?

For example, I've read complaints concerning Ruby's speed in processing
large XML files.   REXML is pure Ruby, and the speed just can't match a
C-based parser.

So what if REXML, or just parts of it, were re-written in C?  Fair game?

Or simply include libxml or expat in the core Ruby distribution, and
include a Ruby binding?

Not advocating, just using XML parsing as an example.  Partly though
because, by comparison, Ruby ships with a YAML parser written in C.  So,
in principle, I would imagine that a C-based XML parser would be at
least eligible for consideration.  In general, though, what are the
criteria for such consideration?

Some issues I can think of for deciding to include C code:

  * License: Code would need to be compatible with/equivalent to
    Ruby's license
  * Flexibility/Access: Pure-Ruby libs are available for metaprogramming;
    I can, in the REXML example, dynamically munge the workings of the
    parser, something that might vanish were parts replaced with C
  * Compilation: Adding more C ups the chance that someone, somewhere,
    will not be able to build Ruby on some platform.  Or move it to Rite.
  * Maintenance/Ownership: Does it make sense to ship a library, such as
    expat, that is maintained outside of the Ruby core?
    If code is added to the core, does it make Ruby harder/easier to
    maintain?



James