Saturday, June 30, 2007

rocaml interview leftovers

I put together a mini-interview with Mauricio Fernandez about his new Ruby/OCaml bridge, rocaml. You can read most of it over at Linux Journal, but here’s a little bit that didn’t fit in too well over there.


zenspider has talked before about wanting to build a OCaml module for RubyInline, what are the chances that you and ROCaml might become involved in something like that?

I am not sold on the advantages of RubyInline in the case of Objective Caml, and its philosophy differs to some extent from rocaml’s, as exemplified by the way it converts Ruby values into native OCaml types and vice versa.

RubyInline makes sense for C because it can be used for small routines that can make use of low-level knowledge of the implementation (such as the RArray, RString, RFloat, etc. structures) to make some operation faster. This is where embedding C code in your Ruby sources is a good idea, since creating an extconf.rb and a separate source file just isn’t worth it for a function taking but a few lines of code. On the other hand, when you don’t need access to Ruby’s C API and your C code is pretty general (except maybe for the fact that it takes simple Ruby VALUEs), putting it in a separate file seems more sensible.

rocaml, on the other hand, is more about writing OCaml code that doesn’t know it’s being called from Ruby, both for practical (code reuse, ability to migrate more functionality from Ruby to OCaml if needed…) and efficiency reasons.

Adding OCaml support to RubyInline via rocaml is not amongst my priorities; as I said, it doesn’t make that much sense for the kind of things I’m using rocaml for at the moment. But it doesn’t seem hard, so I will take a look at it.

No comments:

Post a Comment